32 #ifndef CFI_FDSTREAM_H
33 #define CFI_FDSTREAM_H
71 FD(
const std::string & name,
int mode,
bool lock );
77 FD(
int x ) : fd(x), locked(false) {}
83 operator int () {
return fd; }
90 static void report( std::ostream &s,
int fd);
193 fdostream(
int fd,
bool isCloseNeeded =
false );
294 fdistream(
int fd,
bool isCloseNeeded =
false );
FD(const std::string &name, int mode, bool lock)
constructor which opens the file
Definition: fd.cpp:35
~FD()
destructor
Definition: fd.cpp:62
int flushBuffer()
Flush the characters in the buffer.
Definition: fdostream.cpp:77
virtual ~fdinbuf()
destructor.
Definition: fdistream.cpp:59
A file descriptor input stream.
Definition: fdstream.h:274
static const int PUSHBACK_SIZE
maximum number of push back characters supported
Definition: fdstream.h:226
bool mIsCloseNeeded
Whether the file descriptor needs to be closed on destruction.
Definition: fdstream.h:223
An output stream buffer.
Definition: fdstream.h:107
fdostream(int fd, bool isCloseNeeded=false)
constructor
Definition: fdostream.cpp:182
virtual int overflow(int c)
Write the indicated character and all previous characters.
Definition: fdostream.cpp:104
fdostream & mOwner
Our owning output stream.
Definition: fdstream.h:111
static bool CLOSE_NEEDED
Flag to indicate file descriptor should be closed.
Definition: fdstream.h:174
static bool CLOSE_NOT_NEEDED
Flag to indicate file descriptor should not be closed.
Definition: fdstream.h:278
static const int BUFFER_SIZE
Size of buffer.
Definition: fdstream.h:225
A file descriptor output stream.
Definition: fdstream.h:171
void close()
Close the output file descriptor.
Definition: fdostream.cpp:139
fdinbuf mBuf
Our input file descriptor stream buffer.
Definition: fdstream.h:284
bool mIsCloseNeeded
Whether the file descriptor needs to be closed on destruction.
Definition: fdstream.h:117
fdistream & mOwner
Our owning input stream.
Definition: fdstream.h:217
Wrap file descriptors in a class to ensure closed.
Definition: fdstream.h:59
int mFd
The input file descriptor.
Definition: fdstream.h:220
virtual int sync()
Flush the data in the buffer.
Definition: fdostream.cpp:128
FD(int x)
constructor for existing file descriptor
Definition: fdstream.h:77
void close()
close the file descriptor
Definition: fdistream.cpp:190
fdoutbuf mBuf
Our output file descriptor stream buffer.
Definition: fdstream.h:181
char mBuffer[BUFFER_SIZE]
Output buffer.
Definition: fdstream.h:123
fdoutbuf(int fd, bool isCloseNeeded, fdostream &owner)
constructor
Definition: fdostream.cpp:39
static void report(std::ostream &s, int fd)
Report the details or status of a file descriptor.
Definition: fd.cpp:71
void close()
close the file descriptor
Definition: fdostream.cpp:191
fdistream(int fd, bool isCloseNeeded=false)
constructor
Definition: fdistream.cpp:181
An input stream buffer.
Definition: fdstream.h:213
int mFd
The output file descriptor.
Definition: fdstream.h:114
virtual int underflow()
read characters from the buffer.
Definition: fdistream.cpp:75
void close()
Close the input file descriptor.
Definition: fdistream.cpp:144
virtual ~fdoutbuf()
destructor.
Definition: fdostream.cpp:54
static bool CLOSE_NEEDED
Flag to indicate file descriptor should be closed.
Definition: fdstream.h:277
char mBuffer[BUFFER_SIZE+PUSHBACK_SIZE]
Definition: fdstream.h:230
static const int BUFFER_SIZE
Output buffer size.
Definition: fdstream.h:120
static bool CLOSE_NOT_NEEDED
Flag to indicate file descriptor should not be closed.
Definition: fdstream.h:175
fdinbuf(int fd, bool isCloseNeeded, fdistream &owner)
constructor
Definition: fdistream.cpp:41