Skip to content

Commit

Permalink
Deploying to gh-pages from @ 46cfdf5 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Viatorus committed Jan 23, 2024
1 parent ea250e5 commit 1697873
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions dist/trunk/emio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,10 @@ class ct_vector {
size_ = new_size;
}

constexpr void clear() noexcept {
size_ = 0;
}

[[nodiscard]] constexpr size_t capacity() const noexcept {
return capacity_;
}
Expand Down Expand Up @@ -1700,6 +1704,15 @@ class memory_buffer final : public buffer {
return std::string{view()};
}

/**
* Resets the buffer's read and write position to the beginning of the internal storage.
*/
constexpr void reset() noexcept {
used_ = 0;
vec_.clear();
static_cast<void>(request_write_area(0, vec_.capacity()));
}

protected:
constexpr result<std::span<char>> request_write_area(const size_t used, const size_t size) noexcept override {
const size_t new_size = vec_.size() + size;
Expand Down Expand Up @@ -1755,6 +1768,13 @@ class span_buffer : public buffer {
return std::string{view()};
}

/**
* Resets the buffer's read and write position to the beginning of the span.
*/
constexpr void reset() noexcept {
this->set_write_area(span_);
}

private:
std::span<char> span_;
};
Expand Down Expand Up @@ -2028,6 +2048,14 @@ class file_buffer final : public buffer {
return success;
}

/**
* Resets the buffer's read and write position to the beginning of the file stream.
*/
constexpr void reset() noexcept {
this->set_write_area(cache_);
std::fseek(file_, 0, SEEK_SET);
}

protected:
result<std::span<char>> request_write_area(const size_t /*used*/, const size_t size) noexcept override {
EMIO_TRYV(flush());
Expand Down

0 comments on commit 1697873

Please sign in to comment.