11void ReplaceAll(std::string& in_out,
const std::string& search,
const std::string& substitute)
13 if (search.empty())
return;
14 in_out = std::regex_replace(in_out, std::regex(search), substitute);
18 : start(buffer.begin()), end(buffer.end()), max_line_length(max_line_length), it(buffer.begin()) {}
30 auto c =
static_cast<char>(*it);
36 const std::string_view untrimmed_line(
reinterpret_cast<const char*
>(std::to_address(line_start)),
count);
38 return std::string(line);
46 throw std::runtime_error(
"max_line_length exceeded by LineReader");
59 if (len == 0)
return "";
60 if (
Remaining() < len)
throw std::runtime_error(
"Not enough data in buffer");
61 std::string
out(
reinterpret_cast<const char*
>(std::to_address(
it)), len);
68 return std::distance(
it,
end);
std::string_view TrimStringView(std::string_view str, std::string_view pattern=" \f\n\r\t\v")
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
size_t Remaining() const
Returns remaining size of bytes in buffer.
std::span< conststd::byte >::iterator it
LineReader(std::span< const std::byte > buffer, size_t max_line_length)
const std::span< conststd::byte >::iterator end
std::string ReadLength(size_t len)
Returns string from current iterator position of specified length if possible and advances iterator o...
const size_t max_line_length
std::optional< std::string > ReadLine()
Returns a string from current iterator position up to (but not including) next and advances iterator...