GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing lirc.org — LIRC libraries: /home/columbus/software/lirc-doc/lib/line_buffer.cpp (6f8ea22 2016-08-09 14:47:27 +0200) Source File
AllClassesFilesFunctionsVariablesTypedefsEnumerationsMacrosModulesPages
line_buffer.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** line_buffer.cpp ****************************************************
3 ***********************************************************************
4 *
5 * line_buffer - line buffer for use with read(2)
6 *
7 * Copyright (c) 2015 Alec Leamas
8 *
9 * */
10
16 #include <errno.h>
17 #include <string.h>
18
19 #include "line_buffer.h"
20
21
23 {
24 return buff.find('\n') != std::string::npos;
25 }
26
27
29 {
30 buff.append(input, size);
31 }
32
33
35 {
36 return buff.c_str();
37 }
38
39
40 std::string LineBuffer::get_next_line()
41 {
42 size_t nl = buff.find('\n');
43 if (nl == std::string::npos)
44 return "";
45 std::string line(buff.substr(0, nl + 1));
46 buff.erase(0, nl + 1);
47
48 /* remove DOS line endings */
49 size_t pos = line.rfind("\r");
50 if (pos == line.size() - 1)
51 line.erase(pos, 1);
52 return line;
53 }
54
55
56 LineBuffer::LineBuffer()
57 {
58 buff = "";
59 }
std::string get_next_line() Return and remove first line in buffer, possibly "". Definition: line_buffer.cpp:40 Implements the line buffer class.
| ||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |