[#BloombergLP-bdls-FdStreamBuf]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::FdStreamBuf
:relfileprefix: ../../
:mrdocs:

Stream buffer associated with an opened file descriptor&period;

== Synopsis

Declared in `&lt;bdls&lowbar;fdstreambuf&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class FdStreamBuf
    : public std::streambuf
----

== Description

This class, derived from the C&plus;&plus; standard library class `bsl&colon;&colon;streambuf`, is a mechanism that can be associated with an opened file descriptor, and, except for changing the locale, enables the caller to invoke all the standard `bsl&colon;&colon;streambuf` operations on that file descriptor&period; Note that objects of this class are always in exactly one of the 5 modes outlined in the enum `FdStreamBuf&colon;&colon;FdStreamBufMode`&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `std::streambuf`
| 
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/FdStreamBuf/2constructor.adoc[`FdStreamBuf`]         [.small]#[constructor]#
| Create a stream buffer associated with the specified file descriptor&period;
| xref:BloombergLP/bdls/FdStreamBuf/2destructor.adoc[`&#126;FdStreamBuf`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this object and, if `willCloseOnReset` is `true`, close the file descriptor associated with this object, if any&period;
| xref:BloombergLP/bdls/FdStreamBuf/clear.adoc[`clear`] 
| Release any file descriptor associated with this stream buffer&period;
| xref:BloombergLP/bdls/FdStreamBuf/fileDescriptor.adoc[`fileDescriptor`] 
| Return the file descriptor associated with this object, or `FilesystemUtil&colon;&colon;k&lowbar;INVALID&lowbar;FD` if this object is not currently associated with a file descriptor&period;
| xref:BloombergLP/bdls/FdStreamBuf/isOpened.adoc[`isOpened`] 
| Return `true` if this object is currently associated with a file descriptor, and `false` otherwise&period;
| xref:BloombergLP/bdls/FdStreamBuf/release.adoc[`release`] 
| Disassociate this stream buffer from its file descriptor without closing it&period;
| xref:BloombergLP/bdls/FdStreamBuf/reset.adoc[`reset`] 
| Associate this object with the specified file descriptor&period;
| xref:BloombergLP/bdls/FdStreamBuf/willCloseOnReset.adoc[`willCloseOnReset`] 
| Return `true` if this object will close the associated file descriptor the next time it is reset, cleared, or destroyed, and `false` otherwise&period;
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdls/FdStreamBuf/imbue.adoc[`imbue`]  [.small]#[virtual]#
| Set the locale for this object&period; This method has no effect&period; The behavior is undefined unless the specified `locale` is the same as `bsl&colon;&colon;locale()`&period;
| xref:BloombergLP/bdls/FdStreamBuf/overflow.adoc[`overflow`]  [.small]#[virtual]#
| Flush the output buffer, optionally appending character `c` first&period;
| xref:BloombergLP/bdls/FdStreamBuf/pbackfail.adoc[`pbackfail`]  [.small]#[virtual]#
| Put back a character into the input sequence&period;
| xref:BloombergLP/bdls/FdStreamBuf/seekoff.adoc[`seekoff`]  [.small]#[virtual]#
| Set the file pointer associated with the file descriptor according to the specified `offset` and `whence`&colon;
| xref:BloombergLP/bdls/FdStreamBuf/seekpos.adoc[`seekpos`]  [.small]#[virtual]#
| Seek to `offset` bytes from the beginning of the file&period;
| xref:BloombergLP/bdls/FdStreamBuf/setbuf.adoc[`setbuf`]  [.small]#[virtual]#
| Use `buffer` of capacity `numBytes` as this object&apos;s I&sol;O buffer&period;
| xref:BloombergLP/bdls/FdStreamBuf/showmanyc.adoc[`showmanyc`]  [.small]#[virtual]#
| Return the number of characters remaining to be read&period;
| xref:BloombergLP/bdls/FdStreamBuf/sync.adoc[`sync`]  [.small]#[virtual]#
| If in output mode, flush the buffer to the associated file descriptor&semi; otherwise do nothing&period; Return 0 on success, &hyphen;1 otherwise&period;
| xref:BloombergLP/bdls/FdStreamBuf/underflow.adoc[`underflow`]  [.small]#[virtual]#
| Replenish the input buffer and return the next character of input&period;
| xref:BloombergLP/bdls/FdStreamBuf/xsgetn.adoc[`xsgetn`]  [.small]#[virtual]#
| Read up to `numBytes` characters into `buffer`&period;
| xref:BloombergLP/bdls/FdStreamBuf/xsputn.adoc[`xsputn`]  [.small]#[virtual]#
| Write up to `numBytes` characters from `buffer`&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
