LIRC libraries
LinuxInfraredRemoteControl
 All Classes Files Functions Variables Typedefs Enumerations Macros Modules Pages
line_buffer.h
Go to the documentation of this file.
1 /******************************************************************
2 ** line_buffer ****************************************************
3 *******************************************************************
4 *
5 * Line buffered input on top of e. g., read(2).
6 *
7 * Copyright (c) 2015 Alec Leamas
8 *
9 * */
10 
16 #ifndef LIB_LINE_BUFFER_H_
17 #define LIB_LINE_BUFFER_H_
18 
19 #include <string>
20 
21 
23 class LineBuffer {
24  private:
25  std::string buff;
26 
27  public:
29  void append(const char* line, size_t size);
30 
32  bool has_lines();
33 
35  const char* c_str();
36 
38  std::string get_next_line();
39 
40  LineBuffer();
41 };
42 
43 #endif // LIB_LINE_BUFFER_H_
std::string get_next_line()
Return and remove first line in buffer, possibly "".
Definition: line_buffer.cpp:40
const char * c_str()
Peek the complete buffer contents.
Definition: line_buffer.cpp:34
After appending, data can be retrieved as lines.
Definition: line_buffer.h:23
void append(const char *line, size_t size)
Insert data in buffer.
Definition: line_buffer.cpp:28
bool has_lines()
Check if get_next_line() returns a non-empty string.
Definition: line_buffer.cpp:22