16 if (
search.empty())
return;
18 if (pos == std::string::npos)
return;
22 result.reserve(
in_out.size());
23 std::string::size_type start{0};
24 for (; pos != std::string::npos; pos =
in_out.find(
search, start)) {
26 start = pos +
search.size();
28 result.append(
in_out, start);
50 if (!line.empty() && line.back() ==
'\r')
51 line.remove_suffix(1);
60 throw std::runtime_error(
"max_line_length exceeded by LineReader");
73 if (len == 0)
return {};
74 if (
Remaining() < len)
throw std::runtime_error(
"Not enough data in buffer");
75 std::string_view out(std::to_address(
m_it), len);
87 return std::distance(
m_str.begin(),
m_it);
const size_t m_max_line_length
size_t Consumed() const
Returns number of bytes already read from buffer.
std::optional< std::string_view > ReadLine() LIFETIMEBOUND
Returns a string from current iterator position up to (but not including) next and advances iterator...
size_t Remaining() const
Returns remaining size of bytes in buffer.
const std::string_view m_str
LineReader(std::string_view str LIFETIMEBOUND, size_t max_line_length)
std::string_view ReadLength(size_t len) LIFETIMEBOUND
Returns string from current iterator position of specified length if possible and advances iterator o...
std::string_view::iterator m_it
void ReplaceAll(std::string &in_out, std::string_view search, std::string_view substitute)
Replace every non-overlapping occurrence of search with substitute, treating both literally; the repl...
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.