Split sources, made separate headers
Makefile will autogenerate library header, excluding lines containing "@exclude"
This commit is contained in:
37
src/fdistream.hpp
Normal file
37
src/fdistream.hpp
Normal 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_
|
Reference in New Issue
Block a user