Files
UltraGrid/gui/QT/util/line_buffer.hpp
2022-10-05 15:52:17 +02:00

30 lines
472 B
C++

#ifndef LINE_BUFFER_5dd68dbd1e7b
#define LINE_BUFFER_5dd68dbd1e7b
#include <string>
#include <string_view>
class LineBuffer{
public:
void write(std::string_view str);
bool hasLine() const { return startIdx != endIdx; }
//valid only until pop()
std::string_view peek() const {
return std::string_view(buf.data() + startIdx, endIdx - startIdx);
}
void pop();
private:
void reduceBuf();
std::string buf;
size_t startIdx = 0;
size_t endIdx = 0;
};
#endif