nngn
Loading...
Searching...
No Matches
reader.h
Go to the documentation of this file.
1
#ifndef NNGN_SCRIPTS_READER_H
2
#define NNGN_SCRIPTS_READER_H
3
4
#include <cstddef>
5
#include <sstream>
6
#include <string>
7
#include <vector>
8
9
class
LineReader
{
10
std::string
buf
= std::string(4096, 0);
11
std::stringstream
ss
= {};
12
bool
next_line
(std::string *
s
);
13
public
:
14
std::ptrdiff_t
read
(
int
fd
);
15
template
<
typename
T>
bool
for_each
(
T
f
);
16
};
17
18
bool
LineReader::for_each
(
auto
f
) {
19
std::string
l
;
20
while
(this->
next_line
(&l))
21
if
(!
f
(std::string_view{
l
}))
22
return
false
;
23
return
true
;
24
}
25
26
#endif
LineReader
Definition
reader.h:9
LineReader::ss
std::stringstream ss
Definition
reader.h:11
LineReader::for_each
bool for_each(T f)
Definition
reader.h:18
LineReader::next_line
bool next_line(std::string *s)
Definition
reader.cpp:29
LineReader::buf
std::string buf
Definition
reader.h:10
LineReader::read
std::ptrdiff_t read(int fd)
Definition
reader.cpp:10
T
#define T(f0, f1, f2)
l
local l
Definition
light.lua:23
f
local function f()) end
s
std::chrono::seconds s
Definition
timing.cpp:6
fd
std::chrono::duration< float, typename T::period > fd
Definition
timing.cpp:8
tools
reader.h
Generated by
1.11.0