aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/kstd/bits/format/vformat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kstd/kstd/bits/format/vformat.cpp')
-rw-r--r--libs/kstd/kstd/bits/format/vformat.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/libs/kstd/kstd/bits/format/vformat.cpp b/libs/kstd/kstd/bits/format/vformat.cpp
index 1bf293a4..7210a0b6 100644
--- a/libs/kstd/kstd/bits/format/vformat.cpp
+++ b/libs/kstd/kstd/bits/format/vformat.cpp
@@ -1,6 +1,7 @@
-#include <kstd/format>
-#include <kstd/string>
+#include <kstd/format.hpp>
+#include <kstd/string.hpp>
+#include <algorithm>
#include <cstddef>
#include <iterator>
#include <string_view>
@@ -221,4 +222,23 @@ namespace kstd::bits::format
return m_size;
}
+ auto span_writer::push(std::string_view text) -> void
+ {
+ if (m_position < m_span.size() - 1)
+ {
+ auto space_left = m_span.size() - m_position;
+ auto to_copy = std::min(space_left, text.size());
+ std::ranges::copy_n(text.begin(), to_copy, m_span.subspan(m_position).begin());
+ m_position += to_copy;
+ }
+ }
+
+ auto span_writer::push(char character) -> void
+ {
+ if (m_position < m_span.size() - 1)
+ {
+ m_span[m_position++] = character;
+ }
+ }
+
} // namespace kstd::bits::format \ No newline at end of file