diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-12-19 11:46:46 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-12-19 11:46:46 +0100 |
| commit | de96b0588ab680e1002c12df7ea7900d7eb71cf8 (patch) | |
| tree | 41728f4f5c77a4d96dc3d89096483dfee75b3482 /kapi | |
| parent | 266dde7d535d997a45f6eef41e44ebcaa516b75a (diff) | |
| download | teachos-de96b0588ab680e1002c12df7ea7900d7eb71cf8.tar.xz teachos-de96b0588ab680e1002c12df7ea7900d7eb71cf8.zip | |
kstd: move println to kstd
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/include/kapi/cio.hpp | 100 | ||||
| -rw-r--r-- | kapi/include/kapi/cio/output_device.hpp | 24 |
2 files changed, 33 insertions, 91 deletions
diff --git a/kapi/include/kapi/cio.hpp b/kapi/include/kapi/cio.hpp index 98c715b..30619ec 100644 --- a/kapi/include/kapi/cio.hpp +++ b/kapi/include/kapi/cio.hpp @@ -5,10 +5,8 @@ #include <kstd/format> -#include <array> #include <optional> #include <string_view> -#include <type_traits> namespace teachos::cio { @@ -27,79 +25,31 @@ namespace teachos::cio //! @return The previously active output device. auto set_output_device(output_device & device) -> std::optional<output_device *>; - //! @qualifier kernel-defined - //! Print the given text to the currently active output device. - //! - //! @param text The text to print. - auto print(std::string_view text) -> void; - - //! @qualifier kernel-defined - //! Print the given text, including a newline, to the currently active output device. - //! - //! @param text The text to print. - auto println(std::string_view text) -> void; - - //! @qualifier kernel-defined - //! Print the given error text, to the currently active output device. - //! - //! @param text The error text to print. - auto print_error(std::string_view text) -> void; - - //! @qualifier kernel-defined - //! Print the given error text, including a newline, to the currently active output device. - //! - //! @param text The error text to print. - auto println_error(std::string_view text) -> void; - - template<typename... Args> - // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) - auto print(kstd::format_string<std::type_identity_t<Args>...> format, Args &&... args) -> void - { - auto vprint(std::string_view format, kstd::format_args args) -> void; - auto arguments = std::array{ - kstd::format_arg{&args, kstd::format_dispatcher<std::remove_cvref_t<Args>>} - ... - }; - vprint(format.str, kstd::format_args{arguments.data(), sizeof...(Args)}); - } - - template<typename... Args> - // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) - auto println(kstd::format_string<std::type_identity_t<Args>...> format, Args &&... args) -> void - { - auto vprint(std::string_view format, kstd::format_args args) -> void; - auto arguments = std::array{ - kstd::format_arg{&args, kstd::format_dispatcher<std::remove_cvref_t<Args>>} - ... - }; - vprint(format.str, kstd::format_args{arguments.data(), sizeof...(Args)}); - println(""); - } - - template<typename... Args> - // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) - auto print_error(kstd::format_string<std::type_identity_t<Args>...> format, Args &&... args) -> void - { - auto vprint_error(std::string_view format, kstd::format_args args) -> void; - auto arguments = std::array{ - kstd::format_arg{&args, kstd::format_dispatcher<std::remove_cvref_t<Args>>} - ... - }; - vprint_error(format.str, kstd::format_args{arguments.data(), sizeof...(Args)}); - } - - template<typename... Args> - // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) - auto println_error(kstd::format_string<std::type_identity_t<Args>...> format, Args &&... args) -> void - { - auto vprint_error(std::string_view format, kstd::format_args args) -> void; - auto arguments = std::array{ - kstd::format_arg{&args, kstd::format_dispatcher<std::remove_cvref_t<Args>>} - ... - }; - vprint_error(format.str, kstd::format_args{arguments.data(), sizeof...(Args)}); - println_error(""); - } + auto write(output_stream stream, std::string_view text) -> void; + + // //! @qualifier kernel-defined + // //! Print the given text to the currently active output device. + // //! + // //! @param text The text to print. + // auto print(std::string_view text) -> void; + + // //! @qualifier kernel-defined + // //! Print the given text, including a newline, to the currently active output device. + // //! + // //! @param text The text to print. + // auto println(std::string_view text) -> void; + + // //! @qualifier kernel-defined + // //! Print the given error text, to the currently active output device. + // //! + // //! @param text The error text to print. + // auto print_error(std::string_view text) -> void; + + // //! @qualifier kernel-defined + // //! Print the given error text, including a newline, to the currently active output device. + // //! + // //! @param text The error text to print. + // auto println_error(std::string_view text) -> void; } // namespace teachos::cio diff --git a/kapi/include/kapi/cio/output_device.hpp b/kapi/include/kapi/cio/output_device.hpp index 0599906..bbdf6ed 100644 --- a/kapi/include/kapi/cio/output_device.hpp +++ b/kapi/include/kapi/cio/output_device.hpp @@ -8,6 +8,12 @@ namespace teachos::cio { + enum struct output_stream + { + stdout, + stderr, + }; + //! The interface of a device able to perform character output on a platform. struct output_device { @@ -20,23 +26,9 @@ namespace teachos::cio //! Write the given text to the output device. //! + //! @param stream The stream to write to. //! @param text The text to write. - auto virtual write(std::string_view text) -> void = 0; - - //! Write the given text to the output device, appending a newline - //! - //! @param text The text to write. - auto virtual writeln(std::string_view text) -> void = 0; - - //! Write the given error text to the output device. - //! - //! @param text The text to write. - auto virtual write_error(std::string_view text) -> void = 0; - - //! Write the given error text to the output device, appending a newline - //! - //! @param text The text to write. - auto virtual writeln_error(std::string_view text) -> void = 0; + auto virtual write(output_stream stream, std::string_view text) -> void = 0; protected: output_device() = default; |
