Joedb 10.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
joedb::Abstract_File Class Reference

#include <joedb/journal/Abstract_File.h>

Inheritance diagram for joedb::Abstract_File:

Public Member Functions

 Abstract_File (Open_Mode mode)
bool is_shared () const noexcept
bool is_readonly () const noexcept
Open_Mode get_mode () const noexcept
virtual int64_t get_size () const
 Get the size of the file, or -1 if it is unknown.
virtual size_t pread (char *data, size_t size, int64_t offset) const
 Read a range of bytes.
void full_pread (char *data, size_t size, int64_t offset) const
 Fill the buffer, or throw if the end of the file is reached.
virtual void pwrite (const char *data, size_t size, int64_t offset)
 Write a range of bytes. Extend file size if necessary.
virtual void sync ()
 Write data durably (including file-size change).
virtual void datasync ()
 Write data durably (no file-size change).
virtual void shared_lock (int64_t start, int64_t size)
 Lock a range of bytes for reading (prevents writes, not reads).
virtual void exclusive_lock (int64_t start, int64_t size)
 Lock a range of bytes for writing (prevents both writes and reads).
virtual void unlock (int64_t start, int64_t size) noexcept
 Remove a lock. The range should match the range of a corresponding lock.
void exclusive_lock_tail ()
void unlock_tail () noexcept
void exclusive_lock_head ()
void shared_lock_head ()
void unlock_head () noexcept
std::string read_blob (Blob blob, int64_t max_size=std::numeric_limits< int64_t >::max()) const
virtual void copy_to (Abstract_File &destination, int64_t start, int64_t size) const
virtual bool equal_to (const Abstract_File &destination, int64_t from, int64_t until) const
void copy_to (Abstract_File &destination) const
virtual ~Abstract_File ()=default

Static Public Member Functions

static void reading_past_end_of_file ()

Protected Member Functions

void make_readonly ()
void make_writable ()

Static Protected Attributes

static constexpr int64_t last_position = (1ULL << 63) - 1

Detailed Description

Definition at line 15 of file Abstract_File.h.

Constructor & Destructor Documentation

◆ Abstract_File()

joedb::Abstract_File::Abstract_File ( Open_Mode mode)
inline

Definition at line 26 of file Abstract_File.h.

◆ ~Abstract_File()

virtual joedb::Abstract_File::~Abstract_File ( )
virtualdefault

Member Function Documentation

◆ copy_to() [1/2]

void joedb::Abstract_File::copy_to ( Abstract_File & destination) const
inline

Definition at line 105 of file Abstract_File.h.

◆ copy_to() [2/2]

void joedb::Abstract_File::copy_to ( Abstract_File & destination,
int64_t start,
int64_t size ) const
virtual

Definition at line 39 of file Abstract_File.cpp.

◆ datasync()

virtual void joedb::Abstract_File::datasync ( )
inlinevirtual

Definition at line 65 of file Abstract_File.h.

◆ equal_to()

bool joedb::Abstract_File::equal_to ( const Abstract_File & destination,
int64_t from,
int64_t until ) const
virtual

Definition at line 72 of file Abstract_File.cpp.

◆ exclusive_lock()

virtual void joedb::Abstract_File::exclusive_lock ( int64_t start,
int64_t size )
inlinevirtual

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Posix_File, and joedb::Windows_Handle.

Definition at line 71 of file Abstract_File.h.

◆ exclusive_lock_head()

void joedb::Abstract_File::exclusive_lock_head ( )
inline

Definition at line 79 of file Abstract_File.h.

◆ exclusive_lock_tail()

void joedb::Abstract_File::exclusive_lock_tail ( )
inline

Definition at line 76 of file Abstract_File.h.

◆ full_pread()

void joedb::Abstract_File::full_pread ( char * data,
size_t size,
int64_t offset ) const

Definition at line 12 of file Abstract_File.cpp.

◆ get_mode()

Open_Mode joedb::Abstract_File::get_mode ( ) const
inlinenoexcept

Definition at line 41 of file Abstract_File.h.

◆ get_size()

◆ is_readonly()

bool joedb::Abstract_File::is_readonly ( ) const
inlinenoexcept

Definition at line 36 of file Abstract_File.h.

◆ is_shared()

bool joedb::Abstract_File::is_shared ( ) const
inlinenoexcept

Definition at line 31 of file Abstract_File.h.

◆ make_readonly()

void joedb::Abstract_File::make_readonly ( )
inlineprotected

Definition at line 21 of file Abstract_File.h.

◆ make_writable()

void joedb::Abstract_File::make_writable ( )
inlineprotected

Definition at line 22 of file Abstract_File.h.

◆ pread()

virtual size_t joedb::Abstract_File::pread ( char * data,
size_t size,
int64_t offset ) const
inlinevirtual

The returned value may be less than size, even if the end of the file is not reached. 0 is returned if the end of the file is reached.

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Encoded_File, joedb::Memory_File, joedb::Posix_File, joedb::Readonly_Encoded_File, joedb::Readonly_Memory_File, joedb::Server_File, joedb::SFTP_File, joedb::Stream_File, and joedb::Windows_Handle.

Definition at line 53 of file Abstract_File.h.

◆ pwrite()

virtual void joedb::Abstract_File::pwrite ( const char * data,
size_t size,
int64_t offset )
inlinevirtual

◆ read_blob()

std::string joedb::Abstract_File::read_blob ( Blob blob,
int64_t max_size = std::numeric_limits<int64_t>::max() ) const

Definition at line 139 of file Abstract_File.cpp.

◆ reading_past_end_of_file()

void joedb::Abstract_File::reading_past_end_of_file ( )
static

Definition at line 132 of file Abstract_File.cpp.

◆ shared_lock()

virtual void joedb::Abstract_File::shared_lock ( int64_t start,
int64_t size )
inlinevirtual

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Posix_File, and joedb::Windows_Handle.

Definition at line 68 of file Abstract_File.h.

◆ shared_lock_head()

void joedb::Abstract_File::shared_lock_head ( )
inline

Definition at line 80 of file Abstract_File.h.

◆ sync()

virtual void joedb::Abstract_File::sync ( )
inlinevirtual

◆ unlock()

virtual void joedb::Abstract_File::unlock ( int64_t start,
int64_t size )
inlinevirtualnoexcept

Reimplemented in joedb::Abstract_Interpreted_File, joedb::Posix_File, and joedb::Windows_Handle.

Definition at line 74 of file Abstract_File.h.

◆ unlock_head()

void joedb::Abstract_File::unlock_head ( )
inlinenoexcept

Definition at line 81 of file Abstract_File.h.

◆ unlock_tail()

void joedb::Abstract_File::unlock_tail ( )
inlinenoexcept

Definition at line 77 of file Abstract_File.h.

Member Data Documentation

◆ last_position

int64_t joedb::Abstract_File::last_position = (1ULL << 63) - 1
staticconstexprprotected

Definition at line 23 of file Abstract_File.h.


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