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
9class LineReader {
10 std::string buf = std::string(4096, 0);
11 std::stringstream ss = {};
12 bool next_line(std::string *s);
13public:
14 std::ptrdiff_t read(int fd);
15 template<typename T> bool for_each(T f);
16};
17
18bool 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
Definition: reader.h:9
std::stringstream ss
Definition: reader.h:11
bool for_each(T f)
bool next_line(std::string *s)
std::string buf
Definition: reader.h:10
std::ptrdiff_t read(int fd)
l
Definition: light.lua:23
function f()) end
std::chrono::duration< float, typename T::period > fd
Definition: timing.cpp:8
std::chrono::seconds s
Definition: timing.cpp:6
#define T(f0, f1, f2)