# __gnu_cxx::stdio_filebuf< _CharT, _Traits > Class Template Reference

Provides a layer of compatibility for C/POSIX. More...

`#include <ext/stdio_filebuf.h>`

Inheritance diagram for __gnu_cxx::stdio_filebuf< _CharT, _Traits >:

[legend]
Collaboration diagram for __gnu_cxx::stdio_filebuf< _CharT, _Traits >:

[legend]
List of all members.

## Public Types

typedef _CharT | char_type
typedef _Traits | traits_type
typedef traits_type::int_type | int_type
typedef traits_type::pos_type | pos_type
typedef traits_type::off_type | off_type

## Public Methods

| stdio_filebuf (int __fd, std::ios_base::openmode __mode, bool __del, int_type __size)
| stdio_filebuf (std::__c_file *__f, std::ios_base::openmode __mode, int_type __size=static_cast< int_type >(BUFSIZ))
virtual | ~stdio_filebuf ()
int | fd ()

## Detailed Description

### template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
class __gnu_cxx::stdio_filebuf< _CharT, _Traits >

Provides a layer of compatibility for C/POSIX.

This GNU extension provides extensions for working with standard C FILE*'s and POSIX file descriptors. It must be instantiated by the user with the type of character used in the file stream, e.g., stdio_filebuf<char>.

Definition at line 52 of file stdio_filebuf.h.

## Member Typedef Documentation

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
typedef _CharT __gnu_cxx::stdio_filebuf< _CharT, _Traits >::char_type

| These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation. Reimplemented from std::basic_filebuf< _CharT, _Traits > . Definition at line 56 of file stdio_filebuf.h.

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
typedef traits_type::int_type __gnu_cxx::stdio_filebuf< _CharT, _Traits >::int_type

| These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation. Reimplemented from std::basic_filebuf< _CharT, _Traits > . Definition at line 58 of file stdio_filebuf.h.

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
typedef traits_type::off_type __gnu_cxx::stdio_filebuf< _CharT, _Traits >::off_type

| These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation. Reimplemented from std::basic_filebuf< _CharT, _Traits > . Definition at line 60 of file stdio_filebuf.h.

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
typedef traits_type::pos_type __gnu_cxx::stdio_filebuf< _CharT, _Traits >::pos_type

| These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation. Reimplemented from std::basic_filebuf< _CharT, _Traits > . Definition at line 59 of file stdio_filebuf.h.

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
typedef _Traits __gnu_cxx::stdio_filebuf< _CharT, _Traits >::traits_type

| These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation. Reimplemented from std::basic_filebuf< _CharT, _Traits > . Definition at line 57 of file stdio_filebuf.h.

## Constructor & Destructor Documentation

template<typename _CharT, typename _Traits>
__gnu_cxx::stdio_filebuf< _CharT, _Traits >::stdio_filebuf | ( | int | __fd,
|  | std::ios_base::openmode | __mode,
|  | bool | __del,
|  | int_type | __size
| ) |

Parameters:

  fd | An open file descriptor.
  mode | Same meaning as in a standard filebuf.
  del | Whether to close the file on destruction.
  size | Optimal or preferred size of internal buffer, in bytes.

This constructor associates a file stream buffer with an open POSIX file descriptor. Iff del is true, then the associated file will be closed when the stdio_filebuf is closed/destroyed.

Definition at line 119 of file stdio_filebuf.h.

References std::basic_filebuf< _CharT, _Traits >::is_open() , and std::ios_base::openmode .

template<typename _CharT, typename _Traits>
__gnu_cxx::stdio_filebuf< _CharT, _Traits >::stdio_filebuf | ( | std::__c_file * | __f,
|  | std::ios_base::openmode | __mode,
|  | int_type | __size = static_cast< int_type >(BUFSIZ)
| ) |

Parameters:

  f | An open `FILE*.`
  mode | Same meaning as in a standard filebuf.
  size | Optimal or preferred size of internal buffer, in bytes. Defaults to system's `BUFSIZ.`

This constructor associates a file stream buffer with an open C `FILE*.` The `FILE*` will not be automatically closed when the stdio_filebuf is closed/destroyed.

Definition at line 144 of file stdio_filebuf.h.

References std::basic_filebuf< _CharT, _Traits >::is_open() , and std::ios_base::openmode .

template<typename _CharT, typename _Traits>
__gnu_cxx::stdio_filebuf< _CharT, _Traits >::~stdio_filebuf | ( |  | ) | `[virtual]`

| Possibly closes the external data stream, in the case of the file descriptor constructor and `del` `==` `true.` Definition at line 114 of file stdio_filebuf.h.

## Member Function Documentation

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
int __gnu_cxx::stdio_filebuf< _CharT, _Traits >::fd | ( |  | ) | `[inline]`

Returns:
  The underlying file descriptor.

Once associated with an external data stream, this function can be used to access the underlying POSIX file descriptor. Note that there is no way for the library to track what you do with the descriptor, so be careful.

Definition at line 109 of file stdio_filebuf.h.

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

- stdio_filebuf.h