Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | List of all members
jau::io::ByteOutStream_File Class Referencefinal

File based byte output stream, including named file descriptor. More...

#include <byte_stream.hpp>

Inheritance diagram for jau::io::ByteOutStream_File:
Collaboration diagram for jau::io::ByteOutStream_File:

Public Member Functions

 ByteOutStream_File (const ByteOutStream_File &)=delete
 
 ByteOutStream_File (const int dirfd, const std::string &path, const jau::fs::fmode_t mode=jau::fs::fmode_t::def_file_prot) noexcept
 Construct a stream based byte output stream from filesystem path and parent directory file descriptor, either an existing or new file. More...
 
 ByteOutStream_File (const int fd) noexcept
 Construct a stream based byte output stream by duplicating given file descriptor. More...
 
 ByteOutStream_File (const std::string &path, const jau::fs::fmode_t mode=jau::fs::fmode_t::def_file_prot) noexcept
 Construct a stream based byte output stream from filesystem path, either an existing or new file. More...
 
 ~ByteOutStream_File () noexcept override
 
void close () noexcept override
 Close the stream if supported by the underlying mechanism. More...
 
int fd () const noexcept
 Returns the file descriptor if is_open(), otherwise -1 for no file descriptor. More...
 
std::string id () const noexcept override
 return the id of this data source More...
 
bool is_open () const noexcept override
 Checks if the stream has an associated file. More...
 
ByteOutStream_Fileoperator= (const ByteOutStream_File &)=delete
 
uint64_t tellp () const noexcept override
 Returns the output position indicator. More...
 
std::string to_string () const noexcept override
 
size_t write (const void *, size_t) noexcept override
 Write to the data sink. More...
 
- Public Member Functions inherited from jau::io::ByteOutStream
 ByteOutStream ()=default
 
 ByteOutStream (const ByteOutStream &)=delete
 
 ~ByteOutStream () noexcept override=default
 
virtual void close () noexcept=0
 Close the stream if supported by the underlying mechanism. More...
 
virtual std::string id () const noexcept
 return the id of this data source More...
 
virtual bool is_open () const noexcept=0
 Checks if the stream has an associated file. More...
 
ByteOutStreamoperator= (const ByteOutStream &)=delete
 
virtual uint64_t tellp () const noexcept=0
 Returns the output position indicator. More...
 
virtual std::string to_string () const noexcept=0
 
bool write (const uint8_t &in) noexcept
 Write one byte. More...
 
virtual size_t write (const void *in, size_t length) noexcept=0
 Write to the data sink. More...
 
- Public Member Functions inherited from jau::io::iostate_func
 iostate_func () noexcept
 
 iostate_func (const iostate_func &o) noexcept=default
 
 iostate_func (iostate_func &&o) noexcept=default
 
virtual ~iostate_func () noexcept=default
 
bool bad () const noexcept
 Checks if a non-recoverable error has occurred. More...
 
virtual void clear (const iostate state=iostate::goodbit) noexcept
 Clears state flags by assignment to the given value. More...
 
bool eof () const noexcept
 Checks if end-of-file has been reached. More...
 
bool fail () const noexcept
 Checks if an error has occurred. More...
 
bool good () const noexcept
 Checks if no error nor eof() has occurred i.e. More...
 
 operator bool () const noexcept
 Checks if no error has occurred, synonym of !fail(). More...
 
bool operator! () const noexcept
 Checks if an error has occurred, synonym of fail(). More...
 
iostate_funcoperator= (const iostate_func &o) noexcept=default
 
iostate_funcoperator= (iostate_func &&o) noexcept=default
 
virtual iostate rdstate () const noexcept
 Returns the current state flags. More...
 
void setstate (const iostate state) noexcept
 Sets state flags, by keeping its previous bits. More...
 
bool timeout () const noexcept
 Checks if a timeout (non-recoverable) has occurred. More...
 

Additional Inherited Members

- Protected Member Functions inherited from jau::io::iostate_func
constexpr iostate rdstate_impl () const noexcept
 
constexpr void setstate_impl (iostate state) const noexcept
 

Detailed Description

File based byte output stream, including named file descriptor.

Definition at line 860 of file byte_stream.hpp.

Constructor & Destructor Documentation

◆ ByteOutStream_File() [1/4]

ByteOutStream_File::ByteOutStream_File ( const std::string &  path,
const jau::fs::fmode_t  mode = jau::fs::fmode_t::def_file_prot 
)
noexcept

Construct a stream based byte output stream from filesystem path, either an existing or new file.

In case the file already exists, the underlying file offset is positioned at the end of the file.

In case the given path is a local file URI starting with file://, see jau::io::uri::is_local_file_protocol(), the leading file:// is cut off and the remainder being used.

Parameters
paththe path to the file, maybe a local file URI
modefile protection mode for a new file, otherwise ignored.

Definition at line 719 of file byte_stream.cpp.

◆ ByteOutStream_File() [2/4]

ByteOutStream_File::ByteOutStream_File ( const int  dirfd,
const std::string &  path,
const jau::fs::fmode_t  mode = jau::fs::fmode_t::def_file_prot 
)
noexcept

Construct a stream based byte output stream from filesystem path and parent directory file descriptor, either an existing or new file.

In case the file already exists, the underlying file offset is positioned at the end of the file.

In case the given path is a local file URI starting with file://, see jau::io::uri::is_local_file_protocol(), the leading file:// is cut off and the remainder being used.

Parameters
dirfdparent directory file descriptor
paththe path to the file, maybe a local file URI
modefile protection mode for a new file, otherwise ignored.

Definition at line 682 of file byte_stream.cpp.

◆ ByteOutStream_File() [3/4]

ByteOutStream_File::ByteOutStream_File ( const int  fd)
noexcept

Construct a stream based byte output stream by duplicating given file descriptor.

In case the given path is a local file URI starting with file://, see jau::io::uri::is_local_file_protocol(), the leading file:// is cut off and the remainder being used.

Parameters
fdfile descriptor to duplicate leaving the given fd untouched

Definition at line 665 of file byte_stream.cpp.

◆ ByteOutStream_File() [4/4]

jau::io::ByteOutStream_File::ByteOutStream_File ( const ByteOutStream_File )
delete

◆ ~ByteOutStream_File()

jau::io::ByteOutStream_File::~ByteOutStream_File ( )
inlineoverridenoexcept

Definition at line 930 of file byte_stream.hpp.

Member Function Documentation

◆ is_open()

bool jau::io::ByteOutStream_File::is_open ( ) const
inlineoverridevirtualnoexcept

Checks if the stream has an associated file.

Implements jau::io::ByteOutStream.

Definition at line 872 of file byte_stream.hpp.

Here is the caller graph for this function:

◆ write()

size_t ByteOutStream_File::write ( const void *  in,
size_t  length 
)
overridevirtualnoexcept

Write to the data sink.

Moves the internal offset so that every call to write will be appended to the sink.

This method is not blocking beyond the transfer length bytes.

Parameters
inthe input bytes to write out
lengththe length of the byte array in
Returns
length in bytes that were actually written

Implements jau::io::ByteOutStream.

Definition at line 634 of file byte_stream.cpp.

Here is the caller graph for this function:

◆ id()

std::string jau::io::ByteOutStream_File::id ( ) const
inlineoverridevirtualnoexcept

return the id of this data source

Returns
std::string representing the id of this data source

Reimplemented from jau::io::ByteOutStream.

Definition at line 876 of file byte_stream.hpp.

◆ fd()

int jau::io::ByteOutStream_File::fd ( ) const
inlinenoexcept

Returns the file descriptor if is_open(), otherwise -1 for no file descriptor.

See also
is_open()

Definition at line 883 of file byte_stream.hpp.

◆ operator=()

ByteOutStream_File & jau::io::ByteOutStream_File::operator= ( const ByteOutStream_File )
delete

◆ close()

void ByteOutStream_File::close ( )
overridevirtualnoexcept

Close the stream if supported by the underlying mechanism.

Implements jau::io::ByteOutStream.

Definition at line 722 of file byte_stream.cpp.

Here is the caller graph for this function:

◆ tellp()

uint64_t jau::io::ByteOutStream_File::tellp ( ) const
inlineoverridevirtualnoexcept

Returns the output position indicator.

Returns
number of bytes written so far.

Implements jau::io::ByteOutStream.

Definition at line 932 of file byte_stream.hpp.

Here is the caller graph for this function:

◆ to_string()

std::string ByteOutStream_File::to_string ( ) const
overridevirtualnoexcept

Implements jau::io::ByteOutStream.

Definition at line 730 of file byte_stream.cpp.

Here is the caller graph for this function:

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