aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-20 14:11:07 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-20 14:11:07 +0100
commit5f7d5c6dafd97b0fe59fdaadc3d87dc02f69c218 (patch)
treecc3933b3e88f8659e5c2e37ff2f7dc4f9bf3a015 /libs
parent07cb15c42c16497b0b09b75886ce3baddeaaafb3 (diff)
downloadteachos-5f7d5c6dafd97b0fe59fdaadc3d87dc02f69c218.tar.xz
teachos-5f7d5c6dafd97b0fe59fdaadc3d87dc02f69c218.zip
kstd/fmt: clean up naming
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/include/kstd/bits/format/formatter/bool.hpp2
-rw-r--r--libs/kstd/include/kstd/bits/format/formatter/integral.hpp2
-rw-r--r--libs/kstd/include/kstd/bits/format/formatter/ordering.hpp6
-rw-r--r--libs/kstd/include/kstd/bits/format/specifiers.hpp46
-rw-r--r--libs/kstd/include/kstd/bits/format/string.hpp1
5 files changed, 29 insertions, 28 deletions
diff --git a/libs/kstd/include/kstd/bits/format/formatter/bool.hpp b/libs/kstd/include/kstd/bits/format/formatter/bool.hpp
index bb6cacf..b409e06 100644
--- a/libs/kstd/include/kstd/bits/format/formatter/bool.hpp
+++ b/libs/kstd/include/kstd/bits/format/formatter/bool.hpp
@@ -16,7 +16,7 @@ namespace kstd
template<>
struct formatter<bool>
{
- bits::format::format_specifiers specifiers{};
+ bits::format::specifiers specifiers{};
constexpr auto parse(format_parse_context & context) -> format_parse_context::iterator
{
diff --git a/libs/kstd/include/kstd/bits/format/formatter/integral.hpp b/libs/kstd/include/kstd/bits/format/formatter/integral.hpp
index b0caed1..d5cd6c5 100644
--- a/libs/kstd/include/kstd/bits/format/formatter/integral.hpp
+++ b/libs/kstd/include/kstd/bits/format/formatter/integral.hpp
@@ -21,7 +21,7 @@ namespace kstd
template<std::integral T>
struct formatter<T>
{
- bits::format::format_specifiers specifiers{};
+ bits::format::specifiers specifiers{};
constexpr auto static maximum_digits = 80;
diff --git a/libs/kstd/include/kstd/bits/format/formatter/ordering.hpp b/libs/kstd/include/kstd/bits/format/formatter/ordering.hpp
index 78e7f7b..758285d 100644
--- a/libs/kstd/include/kstd/bits/format/formatter/ordering.hpp
+++ b/libs/kstd/include/kstd/bits/format/formatter/ordering.hpp
@@ -14,7 +14,7 @@ namespace kstd
template<>
struct formatter<std::strong_ordering>
{
- bits::format::format_specifiers specifiers{};
+ bits::format::specifiers specifiers{};
constexpr auto parse(format_parse_context & context) -> format_parse_context::iterator
{
@@ -47,7 +47,7 @@ namespace kstd
template<>
struct formatter<std::weak_ordering>
{
- bits::format::format_specifiers specifiers{};
+ bits::format::specifiers specifiers{};
constexpr auto parse(format_parse_context & context) -> format_parse_context::iterator
{
@@ -76,7 +76,7 @@ namespace kstd
template<>
struct formatter<std::partial_ordering>
{
- bits::format::format_specifiers specifiers{};
+ bits::format::specifiers specifiers{};
constexpr auto parse(format_parse_context & context) -> format_parse_context::iterator
{
diff --git a/libs/kstd/include/kstd/bits/format/specifiers.hpp b/libs/kstd/include/kstd/bits/format/specifiers.hpp
index 85581e6..9bc66c7 100644
--- a/libs/kstd/include/kstd/bits/format/specifiers.hpp
+++ b/libs/kstd/include/kstd/bits/format/specifiers.hpp
@@ -35,7 +35,7 @@ namespace kstd::bits::format
dynamic_argument_id
};
- struct format_specifiers
+ struct specifiers
{
char fill{' '};
alignment align{};
@@ -48,37 +48,37 @@ namespace kstd::bits::format
char type{};
};
- struct format_padding
+ struct padding
{
std::size_t left{};
std::size_t right{};
};
- constexpr auto parse_format_specifiers(format_parse_context & context) -> format_specifiers
+ constexpr auto parse_format_specifiers(format_parse_context & context) -> specifiers
{
- auto specifiers = format_specifiers{};
+ auto specs = specifiers{};
auto it = context.begin();
auto const end = context.end();
if (it != end && *it == '}')
{
- return specifiers;
+ return specs;
}
if (std::next(it) != end && ((*std::next(it)) == '<' || (*std::next(it)) == '>' || (*std::next(it)) == '^'))
{
- specifiers.fill = *it;
+ specs.fill = *it;
switch (*std::next(it))
{
case '<':
- specifiers.align = alignment::left;
+ specs.align = alignment::left;
break;
case '>':
- specifiers.align = alignment::right;
+ specs.align = alignment::right;
break;
case '^':
default:
- specifiers.align = alignment::center;
+ specs.align = alignment::center;
break;
}
std::advance(it, 2);
@@ -88,14 +88,14 @@ namespace kstd::bits::format
switch (*it)
{
case '<':
- specifiers.align = alignment::left;
+ specs.align = alignment::left;
break;
case '>':
- specifiers.align = alignment::right;
+ specs.align = alignment::right;
break;
case '^':
default:
- specifiers.align = alignment::center;
+ specs.align = alignment::center;
break;
}
std::advance(it, 1);
@@ -106,14 +106,14 @@ namespace kstd::bits::format
switch (*it)
{
case '+':
- specifiers.sign = sign_mode::plus;
+ specs.sign = sign_mode::plus;
break;
case '-':
- specifiers.sign = sign_mode::minus;
+ specs.sign = sign_mode::minus;
break;
case ' ':
default:
- specifiers.sign = sign_mode::space;
+ specs.sign = sign_mode::space;
break;
}
std::advance(it, 1);
@@ -121,19 +121,19 @@ namespace kstd::bits::format
if (it != end && *it == '#')
{
- specifiers.alternative_form = true;
+ specs.alternative_form = true;
std::advance(it, 1);
}
if (it != end && *it == '0')
{
- specifiers.zero_pad = true;
+ specs.zero_pad = true;
std::advance(it, 1);
}
if (it != end && *it == '{')
{
- specifiers.width_mode = width_mode::dynamic_argument_id;
+ specs.width_mode = width_mode::dynamic_argument_id;
std::advance(it, 1);
auto argument_id = 0uz;
@@ -156,24 +156,24 @@ namespace kstd::bits::format
error("Expected '}' for dynamic width.");
}
std::advance(it, 1);
- specifiers.width_value = argument_id;
+ specs.width_value = argument_id;
}
else if (it != end && *it >= '0' && *it <= '9')
{
- specifiers.width_mode = width_mode::static_value;
+ specs.width_mode = width_mode::static_value;
while (it != end && *it >= '0' && *it <= '9')
{
- specifiers.width_value = specifiers.width_value * 10 + static_cast<std::size_t>(*it - '0');
+ specs.width_value = specs.width_value * 10 + static_cast<std::size_t>(*it - '0');
std::advance(it, 1);
}
}
context.advance_to(it);
- return specifiers;
+ return specs;
}
constexpr auto calculate_format_padding(std::size_t target_width, std::size_t content_length,
- alignment requested_alignment, alignment default_alignment) -> format_padding
+ alignment requested_alignment, alignment default_alignment) -> padding
{
if (target_width <= content_length)
{
diff --git a/libs/kstd/include/kstd/bits/format/string.hpp b/libs/kstd/include/kstd/bits/format/string.hpp
index 2e7d60a..edeaed1 100644
--- a/libs/kstd/include/kstd/bits/format/string.hpp
+++ b/libs/kstd/include/kstd/bits/format/string.hpp
@@ -5,6 +5,7 @@
#include "context.hpp"
#include "error.hpp"
+#include "formatter.hpp"
#include "parse_context.hpp"
#include <array>