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.hpp

35 lines
663 B
C++
Raw Normal View History

2016-10-15 21:37:59 +05:00
#ifndef NNTPCHAN_LINE_HPP
#define NNTPCHAN_LINE_HPP
2017-05-03 17:09:23 +05:00
#include "server.hpp"
#include <stdint.h>
2016-10-15 21:37:59 +05:00
namespace nntpchan
{
/** @brief a buffered line reader */
2017-05-03 18:15:06 +05:00
class LineReader
2016-10-15 21:37:59 +05:00
{
public:
2017-05-03 17:09:23 +05:00
LineReader(size_t lineLimit);
2016-10-15 21:37:59 +05:00
/** @brief queue inbound data from connection */
2017-05-03 18:44:42 +05:00
void Data(const char * data, ssize_t s);
2016-10-15 21:37:59 +05:00
2017-05-03 17:09:23 +05:00
/** implements IConnHandler */
virtual bool ShouldClose();
2016-10-15 21:37:59 +05:00
protected:
/** @brief handle a line from the client */
virtual void HandleLine(const std::string & line) = 0;
2017-05-03 17:09:23 +05:00
2016-10-15 21:37:59 +05:00
private:
void OnLine(const char * d, const size_t l);
2017-05-03 17:09:23 +05:00
std::string m_leftovers;
bool m_close;
const size_t lineLimit;
2016-10-15 21:37:59 +05:00
};
}
#endif