From 9c45e9c7df1efa5bc1c8e73b6eaef4726b828d3e Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Tue, 4 Feb 2025 19:59:47 +0100 Subject: add span type --- lib/nes/common/path-builder.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/nes/common/path-builder.hh') diff --git a/lib/nes/common/path-builder.hh b/lib/nes/common/path-builder.hh index 727d18c..b64fb28 100644 --- a/lib/nes/common/path-builder.hh +++ b/lib/nes/common/path-builder.hh @@ -1,6 +1,7 @@ #pragma once #include "nes/common/types.hh" +#include "nes/common/span.hh" #include "nes/common/path-view.hh" #include @@ -9,15 +10,14 @@ namespace nes /// A mutable path with a fixed-length buffer. class path_builder { - char* buffer_{ nullptr }; - u32 buffer_length_{ 0 }; - u32 actual_length_{ 0 }; + span buffer_; + u32 length_{ 0 }; public: - explicit path_builder(char* buffer, u32 buffer_length); + explicit path_builder(span); auto get_components() const -> path_view { return path_view{ get_path() }; } - auto get_path() const -> std::string_view { return std::string_view{ buffer_, actual_length_ }; } + auto get_path() const -> std::string_view { return std::string_view{ buffer_.get_data(), length_ }; } auto push(std::string_view) -> bool; auto pop() -> bool; @@ -31,7 +31,7 @@ namespace nes public: explicit path_buffer() - : path_builder{ buffer_, Capacity } + : path_builder{ buffer_ } { } }; -- cgit v1.3.1