E-MailRelay

Public Types | Public Member Functions | Protected Member Functions | List of all members
G::fbuf< T, N > Class Template Reference

A simple file streambuf using a "file descriptor" and three function pointers for read, write and close operations. More...

`#include <gfbuf.h>`

Inheritance diagram for G::fbuf< T, N >:
[legend]
Collaboration diagram for G::fbuf< T, N >:
[legend]

## Public Types
using | read_fn_t = std::function< ssize_t(T, char *, std::size_t)>
using | write_fn_t = std::function< ssize_t(T, const char *, std::size_t)>
using | close_fn_t = std::function< void(T)>

## Public Member Functions
| fbuf (read_fn_t, write_fn_t, close_fn_t)
| Constructor. Use open() to initialise.
| fbuf (T file, read_fn_t, write_fn_t, close_fn_t)
| Constructor passed an open file descriptor.
| ~fbuf () override
| Destructor. Closes the file. More...
void | open (T file)
| Installs the given file descriptor. More...
T | file () const
| Returns the current file descriptor. More...
| fbuf (const fbuf< T, N > &)=delete
| fbuf (fbuf< T, N > &&)=delete
fbuf< T, N > & | operator= (const fbuf< T, N > &)=delete
fbuf< T, N > & | operator= (fbuf< T, N > &&)=delete

## Protected Member Functions
int | overflow (int c) override
| Called to put a character into the output buffer. More...
int | underflow () override
| Called to pull a character out of the input buffer, and pre-fill the input buffer if necessary. More...
int | sync () final
| Called to sync the stream. More...

## Detailed Description

template<typename T, int N>
class G::fbuf< T, N >

A simple file streambuf using a "file descriptor" and three function pointers for read, write and close operations.

The file descriptor type is templated to allow for non-integer file descriptors, such as std::FILE. Does not support seeking.

Eg:

G::fbuf<int,1024> fbuf( ::open("temp.out",O_WRONLY) , ::read , ::write , ::close ) ;
std::ostream stream( &fbuf ) ;
if( fbuf.file() < 0 )
stream.clear( std::ios_base::failbit ) ;
stream << "hello, world!\n" ;
G::fbuf
A simple file streambuf using a "file descriptor" and three function pointers for read,...
Definition: gfbuf.h:56
G::fbuf::open
void open(T file)
Installs the given file descriptor.
Definition: gfbuf.h:153
G::fbuf::fbuf
fbuf(read_fn_t, write_fn_t, close_fn_t)
Constructor. Use open() to initialise.

The implementation inherits from std::streambuf, overriding overflow(), underflow() and sync() to operate the internal character buffer and file descriptor.

Definition at line 55 of file gfbuf.h.

## Member Typedef Documentation

## ◆ close_fn_t

template<typename T , int N>

using G::fbuf< T, N >::close_fn_t = std::function<void(T)>

Definition at line 60 of file gfbuf.h.

## ◆ read_fn_t

template<typename T , int N>

using G::fbuf< T, N >::read_fn_t = std::function<ssize_t(T,char*,std::size_t)>

Definition at line 58 of file gfbuf.h.

## ◆ write_fn_t

template<typename T , int N>

using G::fbuf< T, N >::write_fn_t = std::function<ssize_t(T,const char*,std::size_t)>

Definition at line 59 of file gfbuf.h.

## Constructor & Destructor Documentation

## ◆ ~fbuf()

template<typename T , int N>

G::fbuf< T, N >::~fbuf
| override

Destructor. Closes the file.

Definition at line 140 of file gfbuf.h.

## Member Function Documentation

## ◆ file()

template<typename T , int N>

T G::fbuf< T, N >::file

Returns the current file descriptor.

Definition at line 236 of file gfbuf.h.

## ◆ open()

template<typename T , int N>

void G::fbuf< T, N >::open | ( | T | file | ) |

Installs the given file descriptor.

Definition at line 153 of file gfbuf.h.

## ◆ overflow()

template<typename T , int N>

int G::fbuf< T, N >::overflow | ( | int | c | ) |
| override protected

Called to put a character into the output buffer.

Definition at line 180 of file gfbuf.h.

## ◆ sync()

template<typename T , int N>

int G::fbuf< T, N >::sync
| final protected

Called to sync the stream.

Definition at line 191 of file gfbuf.h.

## ◆ underflow()

template<typename T , int N>

int G::fbuf< T, N >::underflow
| override protected

Called to pull a character out of the input buffer, and pre-fill the input buffer if necessary.

Definition at line 221 of file gfbuf.h.

The documentation for this class was generated from the following file:

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/glib/gfbuf.h