Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::FileStream Class Reference

Stream backed by std::FILE* (for portability across Windows/POSIX). More...

#include <stream.hpp>

Public Types

enum class  Mode : uint8_t { Read , Write , Append , ReadWrite }

Public Member Functions

 FileStream ()=default
 FileStream (std::string_view path, Mode mode=Mode::Read)
 ~FileStream () override
 FileStream (FileStream &&other) noexcept
FileStream & operator= (FileStream &&other) noexcept
bool open (std::string_view path, Mode mode=Mode::Read)
 Open path with the given mode. Returns true on success.
StreamResult read (std::uint8_t *buffer, std::size_t size) override
 Read up to size bytes into buffer.
StreamResult write (const std::uint8_t *buffer, std::size_t size) override
 Write up to size bytes from buffer.
void close () override
 Close the stream. Idempotent.
bool is_open () const override
 True while the stream is usable for read/write.
bool flush ()
 Flush OS-level buffers to the underlying file.
std::size_t position () const
 Current byte position, or (size_t)-1 on error.

Detailed Description

Stream backed by std::FILE* (for portability across Windows/POSIX).

Not async-friendly by itself — use AsyncStream to dispatch reads/writes to a worker thread.

Member Enumeration Documentation

◆ Mode

enum class pulp::runtime::FileStream::Mode : uint8_t
strong
Enumerator
Read 
Write 
Append 
ReadWrite 

Constructor & Destructor Documentation

◆ FileStream() [1/3]

pulp::runtime::FileStream::FileStream ( )
default

◆ FileStream() [2/3]

pulp::runtime::FileStream::FileStream ( std::string_view path,
Mode mode = Mode::Read )
explicit

◆ ~FileStream()

pulp::runtime::FileStream::~FileStream ( )
override

◆ FileStream() [3/3]

pulp::runtime::FileStream::FileStream ( FileStream && other)
noexcept

Member Function Documentation

◆ close()

void pulp::runtime::FileStream::close ( )
overridevirtual

Close the stream. Idempotent.

Implements pulp::runtime::Stream.

◆ flush()

bool pulp::runtime::FileStream::flush ( )

Flush OS-level buffers to the underlying file.

◆ is_open()

bool pulp::runtime::FileStream::is_open ( ) const
inlineoverridevirtual

True while the stream is usable for read/write.

Implements pulp::runtime::Stream.

◆ open()

bool pulp::runtime::FileStream::open ( std::string_view path,
Mode mode = Mode::Read )

Open path with the given mode. Returns true on success.

◆ operator=()

FileStream & pulp::runtime::FileStream::operator= ( FileStream && other)
noexcept

◆ position()

std::size_t pulp::runtime::FileStream::position ( ) const

Current byte position, or (size_t)-1 on error.

◆ read()

StreamResult pulp::runtime::FileStream::read ( std::uint8_t * buffer,
std::size_t size )
overridevirtual

Read up to size bytes into buffer.

Returns how many bytes were written, or an error. buffer may be partially filled on error.

Implements pulp::runtime::Stream.

◆ write()

StreamResult pulp::runtime::FileStream::write ( const std::uint8_t * buffer,
std::size_t size )
overridevirtual

Write up to size bytes from buffer.

Returns how many bytes were consumed. Partial writes are permitted — callers loop until satisfied or treat the short return as backpressure.

Implements pulp::runtime::Stream.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/stream.hpp