diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-02-04 23:11:08 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-02-04 23:11:08 +0100 |
| commit | 79553ab1fa3d707612e80dd03bf95ca65fa0c411 (patch) | |
| tree | f44bec41548d569cfca43c44e0e4ffa7b72ed4ed /lib/nes/common/path-builder.hh | |
| parent | 9c45e9c7df1efa5bc1c8e73b6eaef4726b828d3e (diff) | |
refactor file browser
Diffstat (limited to 'lib/nes/common/path-builder.hh')
| -rw-r--r-- | lib/nes/common/path-builder.hh | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/nes/common/path-builder.hh b/lib/nes/common/path-builder.hh index b64fb28..e7980ea 100644 --- a/lib/nes/common/path-builder.hh +++ b/lib/nes/common/path-builder.hh @@ -3,6 +3,7 @@ #include "nes/common/types.hh" #include "nes/common/span.hh" #include "nes/common/path-view.hh" +#include "nes/common/status.hh" #include <string_view> namespace nes @@ -10,6 +11,9 @@ namespace nes /// A mutable path with a fixed-length buffer. class path_builder { + template<u32 Capacity> + friend class path_buffer; + span<char> buffer_; u32 length_{ 0 }; @@ -19,8 +23,8 @@ namespace nes auto get_components() const -> path_view { return path_view{ get_path() }; } auto get_path() const -> std::string_view { return std::string_view{ buffer_.get_data(), length_ }; } - auto push(std::string_view) -> bool; - auto pop() -> bool; + auto push(std::string_view) -> status; + auto pop() -> status; }; /// A path builder with a buffer embedded into it. @@ -34,5 +38,18 @@ namespace nes : path_builder{ buffer_ } { } + + path_buffer(path_buffer const& other) + : path_builder{ buffer_ } + { + std::copy_n(other.buffer_, Capacity, buffer_); + length_ = other.length_; + } + + auto operator=(path_buffer const& other) + { + std::copy_n(other.buffer_, Capacity, buffer_); + length_ = other.length_; + } }; } // namespace nes
\ No newline at end of file |
