PST File Format SDK v0.4
Loading...
Searching...
No Matches
pstsdk::node_impl Class Reference

The node implementation. More...

#include <node.h>

+ Inheritance diagram for pstsdk::node_impl:
+ Collaboration diagram for pstsdk::node_impl:

Public Member Functions

 node_impl (const shared_db_ptr &db, const node_info &info)
 Constructor for top level nodes.
 
 node_impl (const std::shared_ptr< node_impl > &container_node, const subnode_info &info)
 Constructor for subnodes.
 
node_imploperator= (const node_impl &other)
 Set one node equal to another.
 
node_id get_id () const
 Get the id of this node.
 
block_id get_data_id () const
 Get the block_id of the data block of this node.
 
block_id get_sub_id () const
 Get the block_id of the subnode block of this node.
 
node_id get_parent_id () const
 Get the parent id.
 
bool is_subnode ()
 Tells you if this is a subnode.
 
std::shared_ptr< data_blockget_data_block () const
 Returns the data block associated with this node.
 
std::shared_ptr< subnode_blockget_subnode_block () const
 Returns the subnode block associated with this node.
 
size_t read (std::vector< byte > &buffer, ulong offset) const
 Read data from this node.
 
template<typename T >
read (ulong offset) const
 Read data from this node.
 
size_t read (std::vector< byte > &buffer, uint page_num, ulong offset) const
 Read data from this node.
 
template<typename T >
read (uint page_num, ulong offset) const
 Read data from a specific block on this node.
 
size_t read_raw (byte *pdest_buffer, size_t size, ulong offset) const
 Read data from this node.
 
size_t size () const
 Returns the size of this node.
 
size_t get_page_size (uint page_num) const
 Returns the size of a page in this node.
 
uint get_page_count () const
 Returns the number of pages in this node.
 
const_subnodeinfo_iterator subnode_info_begin () const
 Returns an iterator positioned at first subnodeinfo.
 
const_subnodeinfo_iterator subnode_info_end () const
 Returns an iterator positioned past the last subnodeinfo.
 
node lookup (node_id id) const
 Lookup a subnode by node id.
 

Detailed Description

The node implementation.

The node class is really divided into two classes, node and node_impl. The purpose of this design is to allow a node to conceptually "outlive" the stack based object encapsulating it. This is necessary if subobjects are opened which still need to refer to their parent. This is accomplished in this case, like others, via having a thin stack based object (node) with a shared pointer to the implemenetation object (node_impl). Subnodes will grab a shared_ptr ref to the parents node_impl.

See the documentation for node to read more about what a node is.

The interface of node_impl follows closely that of node; differing mainly in the construction and destruction semantics plus the addition of some convenience functions.

node and its node_impl class generally have a one to one mapping, this isn't true only if someone opens an alias for a node.

Definition at line 62 of file node.h.

Constructor & Destructor Documentation

◆ node_impl() [1/2]

pstsdk::node_impl::node_impl ( const shared_db_ptr db,
const node_info info 
)
inline

Constructor for top level nodes.

This constructor is specific to nodes defined in the NBT

Parameters
[in]dbThe database context we're located in
[in]infoInformation about this node

Definition at line 70 of file node.h.

◆ node_impl() [2/2]

pstsdk::node_impl::node_impl ( const std::shared_ptr< node_impl > &  container_node,
const subnode_info info 
)
inline

Constructor for subnodes.

This constructor is specific to nodes defined in other nodes

Parameters
[in]container_nodeThe parent or containing node
[in]infoInformation about this node

Definition at line 78 of file node.h.

Member Function Documentation

◆ get_data_block()

std::shared_ptr< data_block > pstsdk::node_impl::get_data_block ( ) const
inline

Returns the data block associated with this node.

Returns
A shared pointer to the data block

Definition at line 116 of file node.h.

◆ get_data_id()

pstsdk::block_id pstsdk::node_impl::get_data_id ( ) const
inline

Get the block_id of the data block of this node.

Returns
The id

Definition at line 874 of file node.h.

◆ get_id()

node_id pstsdk::node_impl::get_id ( ) const
inline

Get the id of this node.

Returns
The id

Definition at line 94 of file node.h.

◆ get_page_count()

pstsdk::uint pstsdk::node_impl::get_page_count ( ) const
inline

Returns the number of pages in this node.

Note
In this context, a "page" is an external block
Returns
The number of pages

Definition at line 900 of file node.h.

◆ get_page_size()

size_t pstsdk::node_impl::get_page_size ( uint  page_num) const
inline

Returns the size of a page in this node.

Note
In this context, a "page" is an external block
Parameters
[in]page_numThe page to get the size of
Returns
The size of the page

Definition at line 895 of file node.h.

◆ get_parent_id()

node_id pstsdk::node_impl::get_parent_id ( ) const
inline

Get the parent id.

The parent id here is the field in the NBT. It is not the id of the container node, if any. Generally the parent id of a message will be a folder, etc.

Returns
The id, zero if this is a subnode

Definition at line 108 of file node.h.

◆ get_sub_id()

pstsdk::block_id pstsdk::node_impl::get_sub_id ( ) const
inline

Get the block_id of the subnode block of this node.

Returns
The id

Definition at line 882 of file node.h.

◆ get_subnode_block()

std::shared_ptr< subnode_block > pstsdk::node_impl::get_subnode_block ( ) const
inline

Returns the subnode block associated with this node.

Returns
A shared pointer to the subnode block

Definition at line 120 of file node.h.

◆ is_subnode()

bool pstsdk::node_impl::is_subnode ( )
inline

Tells you if this is a subnode.

Returns
true if this is a subnode, false otherwise

Definition at line 112 of file node.h.

◆ lookup()

pstsdk::node pstsdk::node_impl::lookup ( node_id  id) const
inline

Lookup a subnode by node id.

Exceptions
key_not_found<node_id>if a subnode with the specified node_id was not found
Parameters
[in]idThe subnode id to find
Returns
The subnode

Definition at line 1407 of file node.h.

◆ operator=()

node_impl & pstsdk::node_impl::operator= ( const node_impl other)
inline

Set one node equal to another.

The assignment semantics of a node cause the assigned to node to refer to the same data on disk as the assigned from node. It still has it's own unique id, parent, etc - only the data contained in this node is 'assigned'

Parameters
[in]otherThe node to assign from
Returns
*this after the assignment is done

Definition at line 89 of file node.h.

◆ read() [1/4]

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

Read data from this node.

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

Note
In this context, a "page" is an external block
Parameters
[in,out]bufferThe buffer to fill
[in]page_numThe page to read from
[in]offsetThe location to read from
Returns
The amount of data read

Definition at line 921 of file node.h.

◆ read() [2/4]

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

Read data from this node.

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 905 of file node.h.

◆ read() [3/4]

template<typename T >
T pstsdk::node_impl::read ( uint  page_num,
ulong  offset 
) const
inline

Read data from a specific block on this node.

Note
In this context, a "page" is an external block
Template Parameters
TThe type to read
Parameters
[in]page_numThe block (ordinal) to read data from
[in]offsetThe offset into that block to read from
Returns
The type read

Definition at line 927 of file node.h.

◆ read() [4/4]

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

Read data from this node.

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 916 of file node.h.

◆ read_raw()

size_t pstsdk::node_impl::read_raw ( byte pdest_buffer,
size_t  size,
ulong  offset 
) const
inline

Read data from this node.

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

Definition at line 910 of file node.h.

◆ size()

size_t pstsdk::node_impl::size ( ) const
inline

Returns the size of this node.

Returns
The node size

Definition at line 890 of file node.h.

◆ subnode_info_begin()

pstsdk::const_subnodeinfo_iterator pstsdk::node_impl::subnode_info_begin ( ) const
inline

Returns an iterator positioned at first subnodeinfo.

Returns
An iterator over subnodeinfos

Definition at line 1395 of file node.h.

◆ subnode_info_end()

pstsdk::const_subnodeinfo_iterator pstsdk::node_impl::subnode_info_end ( ) const
inline

Returns an iterator positioned past the last subnodeinfo.

Returns
An iterator over subnodeinfos

Definition at line 1401 of file node.h.


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