Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libnntpchan/line.cpp
2018-05-06 08:10:20 -04:00

28 lines
561 B
C++

#include <nntpchan/line.hpp>
namespace nntpchan
{
LineReader::LineReader(size_t limit) : m_close(false), lineLimit(limit) {}
void LineReader::Data(const char *data, ssize_t l)
{
if (l <= 0)
return;
m_line << m_leftover;
m_leftover = "";
m_line << std::string(data, l);
for (std::string line; std::getline(m_line, line);)
{
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
HandleLine(line);
}
if (m_line)
m_leftover = m_line.str();
m_line.clear();
}
bool LineReader::ShouldClose() { return m_close; }
}