Split sources, made separate headers

Makefile will autogenerate library header, excluding lines containing "@exclude"
This commit is contained in:
Bob Polis
2022-12-14 16:58:05 +01:00
parent 46e5eb7250
commit 8bfa172675
17 changed files with 718 additions and 208 deletions

37
src/fdistream.hpp Normal file
View File

@ -0,0 +1,37 @@
#ifndef FDISTREAM_H_
#define FDISTREAM_H_
#include <iostream>
#include "fdiobuf.hpp" // @exclude
namespace sc {
namespace io {
class fdistream : public std::istream {
public:
fdistream() : std::istream(&_inbuf), _inbuf(-1) {}
fdistream(int fd) : std::istream(&_inbuf), _inbuf(fd) {}
// no copying
fdistream(const fdistream&) = delete;
fdistream& operator=(const fdistream&) = delete;
// moving allowed
fdistream(fdistream&& other);
fdistream& operator=(fdistream&& other);
// cleanup: fdistream is RAII class for open file descriptor
virtual ~fdistream();
int fd() const { return _inbuf.fd(); }
void fd(int fd) { _inbuf.fd(fd); }
bool is_open() const { return _inbuf.fd() != -1; }
void close();
protected:
fdiobuf _inbuf;
};
}
}
#endif // FDISTREAM_H_