summaryrefslogtreecommitdiff
path: root/lib/nes/common/containers/string-builder.cc
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-02-06 19:54:38 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-02-06 19:54:38 +0100
commit64ebfde8bcd6408e3b6925624e8680c314db6efc (patch)
treeb969314f909f7f16ef5acc63f90dca317a40850a /lib/nes/common/containers/string-builder.cc
parentd060e3a50c987d10799ccc739bdbf9d7d7a13c10 (diff)
get rid of nasty stdlib
Diffstat (limited to 'lib/nes/common/containers/string-builder.cc')
-rw-r--r--lib/nes/common/containers/string-builder.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/nes/common/containers/string-builder.cc b/lib/nes/common/containers/string-builder.cc
index 74d9548..ad2f97f 100644
--- a/lib/nes/common/containers/string-builder.cc
+++ b/lib/nes/common/containers/string-builder.cc
@@ -16,7 +16,7 @@ namespace nes
return status::success;
}
- auto string_builder::append_string(std::string_view const value) -> status
+ auto string_builder::append_string(string_view const value) -> status
{
auto copy = *this;
for (auto const c : value)
@@ -103,13 +103,13 @@ namespace nes
return append_string(value ? "true" : "false");
}
- auto string_builder::append_format(std::string_view const fmt, format_arg const* args, u32 const arg_count) -> status
+ auto string_builder::append_format(string_view const fmt, format_arg const* args, u32 const arg_count) -> status
{
auto copy = *this;
// Go through the format string, inserting the arguments for the templates as necessary.
auto current_arg = u32{ 0 };
- for (auto i = u32{ 0 }; i < fmt.length(); ++i)
+ for (auto i = u32{ 0 }; i < fmt.get_length(); ++i)
{
if (fmt[i] == '{')
{
@@ -122,10 +122,10 @@ namespace nes
else
{
// start of template
- auto const params = &fmt[i]; // remember start position
+ auto const params_start = i; // remember start position
auto params_length = u32{ 0 };
// skip to the end of the template
- while (fmt[i] && fmt[i] != '}')
+ while (i < fmt.get_length() && fmt[i] != '}')
{
params_length++;
i++;
@@ -137,7 +137,7 @@ namespace nes
}
// end of template
- auto const p = std::string_view{ params, params_length };
+ auto const p = fmt.substring(params_start, params_length);
if (current_arg < arg_count)
{
if (auto const s = copy.append_format_arg(args[current_arg], p); s != status::success) { return s; }
@@ -182,11 +182,11 @@ namespace nes
return status::success;
}
- auto string_builder::append_format_arg(format_arg const arg, std::string_view const params) -> status
+ auto string_builder::append_format_arg(format_arg const arg, string_view const params) -> status
{
auto const parse_params = [&]
{
- if (!params.empty())
+ if (!params.is_empty())
{
return status::error_invalid_format_string;
}
@@ -196,7 +196,7 @@ namespace nes
auto const parse_params_integer = [&](number_format& out_format)
{
- if (params.empty() || params == "d")
+ if (params.is_empty() || params == "d")
{
out_format = number_format::decimal;
}