PST File Format SDK v0.4
Loading...
Searching...
No Matches
pstsdk::data_block Class Referenceabstract

A block which represents end user data. More...

#include <node.h>

+ Inheritance diagram for pstsdk::data_block:
+ Collaboration diagram for pstsdk::data_block:

Public Member Functions

 data_block (const shared_db_ptr &db, const block_info &info, size_t total_size)
 Constructor for a data_block.
 
virtual ~data_block ()
 
size_t read (std::vector< byte > &buffer, ulong offset) const
 Read data from this block.
 
template<typename T >
read (ulong offset) const
 Read data from this block.
 
virtual size_t read_raw (byte *pdest_buffer, size_t size, ulong offset) const =0
 Read data from this block.
 
virtual uint get_page_count () const =0
 Get the number of physical pages in this data_block.
 
virtual std::shared_ptr< external_blockget_page (uint page_num) const =0
 Get a specific page of this data_block.
 
size_t get_total_size () const
 Get the total logical size of this block.
 
- Public Member Functions inherited from pstsdk::block
 block (const shared_db_ptr &db, const block_info &info)
 Basic block constructor.
 
virtual ~block ()
 
virtual bool is_internal () const =0
 Returns the blocks internal/external state.
 
size_t get_disk_size () const
 Get the last known size of this block on disk.
 
block_id get_id () const
 Get the block_id of this block.
 
ulonglong get_address () const
 Get the address of this block on disk.
 

Protected Attributes

size_t m_total_size
 the total or logical size (sum of all external child blocks)
 
- Protected Attributes inherited from pstsdk::block
bool m_modified
 True if this block has been modified and needs to be saved.
 
size_t m_size
 The size of this specific block on disk at last save.
 
block_id m_id
 The id of this block.
 
ulonglong m_address
 The address of this specific block on disk, 0 if unknown.
 
weak_db_ptr m_db
 

Additional Inherited Members

- Protected Member Functions inherited from pstsdk::block
shared_db_ptr get_db_ptr () const
 
virtual void trim ()
 

Detailed Description

A block which represents end user data.

This class is the base class of both extended_block and external_block. This base class exists to abstract away their differences, so a node can treat a given block (be it extended or external) simply as a stream of bytes.

Definition at line 550 of file node.h.

Constructor & Destructor Documentation

◆ data_block()

pstsdk::data_block::data_block ( const shared_db_ptr db,
const block_info info,
size_t  total_size 
)
inline

Constructor for a data_block.

Parameters
[in]dbThe database context
[in]infoInformation about this block
[in]total_sizeThe total logical size of this block

Definition at line 557 of file node.h.

◆ ~data_block()

virtual pstsdk::data_block::~data_block ( )
inlinevirtual

Definition at line 559 of file node.h.

Member Function Documentation

◆ get_page()

virtual std::shared_ptr< external_block > pstsdk::data_block::get_page ( uint  page_num) const
pure virtual

Get a specific page of this data_block.

Note
In this context, "page" refers to an external_block
Exceptions
out_of_rangeIf page_num >= get_page_count()
Parameters
[in]page_numThe ordinal of the external_block to get, zero based
Returns
The requested external_block

Implemented in pstsdk::extended_block, and pstsdk::external_block.

◆ get_page_count()

virtual uint pstsdk::data_block::get_page_count ( ) const
pure virtual

Get the number of physical pages in this data_block.

Note
In this context, "page" refers to an external_block
Returns
The total number of external_blocks under this data_block

Implemented in pstsdk::extended_block, and pstsdk::external_block.

◆ get_total_size()

size_t pstsdk::data_block::get_total_size ( ) const
inline

Get the total logical size of this block.

Returns
The total logical size of this block

Definition at line 605 of file node.h.

◆ read() [1/2]

size_t pstsdk::data_block::read ( std::vector< byte > &  buffer,
ulong  offset 
) const
inline

Read data from this block.

Fills the specified buffer with data starting at the specified offset. The size of the buffer indicates how much data to read.

Parameters
[in,out]bufferThe buffer to fill
[in]offsetThe location to read from
Returns
The amount of data read

Definition at line 1060 of file node.h.

◆ read() [2/2]

template<typename T >
T pstsdk::data_block::read ( ulong  offset) const
inline

Read data from this block.

Returns a "T" located as the specified offset

Template Parameters
TThe type to read
Parameters
[in]offsetThe location to read from
Returns
The type read

Definition at line 1076 of file node.h.

◆ read_raw()

virtual size_t pstsdk::data_block::read_raw ( byte pdest_buffer,
size_t  size,
ulong  offset 
) const
pure virtual

Read data from this block.

Parameters
[out]pdest_bufferThe location to read the data into
[in]sizeThe amount of data to read
[in]offsetThe location to read from
Returns
The amount of data read

Implemented in pstsdk::extended_block, and pstsdk::external_block.

Member Data Documentation

◆ m_total_size

size_t pstsdk::data_block::m_total_size
protected

the total or logical size (sum of all external child blocks)

Definition at line 611 of file node.h.


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