foobar2000 SDK  2015-08-03
Public Member Functions | Protected Member Functions | Private Attributes
reader_membuffer_baseabstract

#include <filesystem_helper.h>

+ Inheritance diagram for reader_membuffer_base:

Public Member Functions

 reader_membuffer_base ()
 
bool can_seek ()
 
t_filesize get_position (abort_callback &p_abort)
 
t_filesize get_size (abort_callback &p_abort)
 
bool is_in_memory ()
 
t_size read (void *p_buffer, t_size p_bytes, abort_callback &p_abort)
 
void reopen (abort_callback &p_abort)
 
void seek (t_filesize position, abort_callback &p_abort)
 
void write (const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
 

Protected Member Functions

virtual const void * get_buffer ()=0
 
virtual t_size get_buffer_size ()=0
 
virtual bool get_content_type (pfc::string_base &)
 
virtual t_filetimestamp get_timestamp (abort_callback &p_abort)=0
 
void seek_internal (t_size p_offset)
 

Private Attributes

t_size m_offset
 

Detailed Description

Definition at line 31 of file filesystem_helper.h.

Constructor & Destructor Documentation

reader_membuffer_base::reader_membuffer_base ( )
inline

Definition at line 33 of file filesystem_helper.h.

33 : m_offset(0) {}

Member Function Documentation

bool reader_membuffer_base::can_seek ( )
inline

Definition at line 44 of file filesystem_helper.h.

44 {return true;}
virtual const void* reader_membuffer_base::get_buffer ( )
protectedpure virtual
virtual t_size reader_membuffer_base::get_buffer_size ( )
protectedpure virtual
virtual bool reader_membuffer_base::get_content_type ( pfc::string_base )
inlineprotectedvirtual

Reimplemented in reader_membuffer_mirror.

Definition at line 51 of file filesystem_helper.h.

51 {return false;}
t_filesize reader_membuffer_base::get_position ( abort_callback p_abort)
inline

Definition at line 40 of file filesystem_helper.h.

40 {return m_offset;}
t_filesize reader_membuffer_base::get_size ( abort_callback p_abort)
inline

Definition at line 39 of file filesystem_helper.h.

39 {return get_buffer_size();}
virtual t_size get_buffer_size()=0
virtual t_filetimestamp reader_membuffer_base::get_timestamp ( abort_callback p_abort)
protectedpure virtual
bool reader_membuffer_base::is_in_memory ( )
inline

Definition at line 45 of file filesystem_helper.h.

45 {return true;}
t_size reader_membuffer_base::read ( void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)

Definition at line 89 of file filesystem_helper.cpp.

89  {
90  p_abort.check_e();
91  t_size max = get_buffer_size();
92  if (max < m_offset) uBugCheck();
93  max -= m_offset;
94  t_size delta = p_bytes;
95  if (delta > max) delta = max;
96  memcpy(p_buffer,(char*)get_buffer() + m_offset,delta);
97  m_offset += delta;
98  return delta;
99 }
virtual const void * get_buffer()=0
size_t t_size
Definition: int_types.h:48
virtual t_size get_buffer_size()=0
PFC_NORETURN void SHARED_EXPORT uBugCheck()
void reader_membuffer_base::reopen ( abort_callback p_abort)
inline

Definition at line 42 of file filesystem_helper.h.

42 {seek(0,p_abort);}
void seek(t_filesize position, abort_callback &p_abort)
void reader_membuffer_base::seek ( t_filesize  position,
abort_callback p_abort 
)

Definition at line 101 of file filesystem_helper.cpp.

101  {
102  p_abort.check_e();
103  t_filesize max = get_buffer_size();
104  if (position == filesize_invalid || position > max) throw exception_io_seek_out_of_range();
105  m_offset = (t_size)position;
106 }
static const t_filesize filesize_invalid
Invalid/unknown file size constant. Also see: t_filesize.
Definition: filesystem.h:16
size_t t_size
Definition: int_types.h:48
t_uint64 t_filesize
Type used for file size related variables.
Definition: filesystem.h:8
virtual t_size get_buffer_size()=0
void reader_membuffer_base::seek_internal ( t_size  p_offset)
inlineprotected

Definition at line 52 of file filesystem_helper.h.

52 {if (p_offset > get_buffer_size()) throw exception_io_seek_out_of_range(); m_offset = p_offset;}
virtual t_size get_buffer_size()=0
void reader_membuffer_base::write ( const void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)
inline

Definition at line 37 of file filesystem_helper.h.

37 {throw exception_io_denied();}

Field Documentation

t_size reader_membuffer_base::m_offset
private

Definition at line 54 of file filesystem_helper.h.


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