lfp_protocol interface¶
#include <lfp/protocol.hpp>
-
class lfp_protocol¶
The functions of this class roughly correspond to the public interface in lfp.h, but with C++-isms.
Since it is not exposed in the ABI except through pointers, it can be a lot more volatile and can change quite dramatically between versions.
When methods have default implementations, they typically just return
LFP_NOTIMPLEMENTED
.Public Functions
-
virtual void close() noexcept(false) = 0¶
Close the file and release resources.
Multiple calls to ‘close’ must be allowed in order to correctly handle nested protocols.
-
virtual lfp_status readinto(void *dst, std::int64_t len, std::int64_t *bytes_read) noexcept(false) = 0¶
Read len bytes into dst.
This must be implemented by all protocols.
- Parameters:
dst – buffer of size
len
len – maximum length of data to be read
bytes_read – number of bytes actually read into the buffer
-
virtual void seek(std::int64_t) noexcept(false)¶
Set the file position to (absolute) byte offset n.
If this is not implemented,
lfp_seek()
will always returnLFP_NOTIMPLEMENTED
.
-
virtual std::int64_t tell() const noexcept(false)¶
Get current position.
If this is not implemented,
lfp_tell()
will always returnLFP_NOTIMPLEMENTED
.
-
virtual std::int64_t ptell() const noexcept(false)¶
Get current physical position.
If this is not implemented,
lfp_ptell()
will always returnLFP_NOTIMPLEMENTED
.
-
virtual lfp_protocol *peel() noexcept(false) = 0¶
Peels off the current protocol to expose the underlying one.
If this is not implemented,
lfp_peel()
will throwLFP_NOTIMPLEMENTED
.
-
virtual lfp_protocol *peek() const noexcept(false) = 0¶
Expose a const view of the underlying protocol.
If this is not implemented,
lfp_peek()
will throwLFP_NOTIMPLEMENTED
.
-
const char *errmsg() noexcept(true)¶
Get last set error message.
-
void errmsg(std::string) noexcept(false)¶
Set the error message.
-
virtual void close() noexcept(false) = 0¶