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
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)
Definition reader.h:18
bool next_line(std::string *s)
Definition reader.cpp:29
std::string buf
Definition reader.h:10
std::ptrdiff_t read(int fd)
Definition reader.cpp:10
#define T(f0, f1, f2)
local l
Definition light.lua:23
local function f()) end
std::chrono::seconds s
Definition timing.cpp:6
std::chrono::duration< float, typename T::period > fd
Definition timing.cpp:8