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

An in memory representation of the "node" concept in a PST data file. More...

#include <node.h>

+ Collaboration diagram for pstsdk::node:

Public Types

typedef boost::transform_iterator< subnode_transform_info, const_subnodeinfo_iteratorsubnode_iterator
 A transform iterator, so we can expose the subnodes as a collection of nodes rather than subnode_info objects.
 

Public Member Functions

 node (const shared_db_ptr &db, const node_info &info)
 Constructor for top level nodes.
 
 node (const node &container_node, const subnode_info &info)
 Constructor for subnodes.
 
 node (const std::shared_ptr< node_impl > &container_node, const subnode_info &info)
 Constructor for subnodes.
 
 node (const node &other)
 Copy construct this node.
 
 node (const node &other, alias_tag)
 Alias constructor.
 
 node (node &&other)
 Move constructor.
 
nodeoperator= (const node &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.
 
node_stream_device open_as_stream ()
 Creates a stream device over 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.
 
subnode_iterator subnode_begin () const
 Returns a proxy iterator for the first subnode.
 
subnode_iterator subnode_end () const
 Returns a proxy iterator positioned past the last subnode.
 
node lookup (node_id id) const
 Lookup a subnode by node id.
 

Detailed Description

An in memory representation of the "node" concept in a PST data file.

A node is the primary abstraction exposed by the NDB Layer to the upper layers. It's purpose is to abstract away the details of working with immutable blocks and subnode blocks. It can therefor be thought of simply as a mutable stream of bytes and a collection of sub nodes, themselves a mutable stream of bytes potentially with another collection of subnodes, etc.

When using the node class, think of it as creating an in memory "instance" of the node on the disk. You can have several in memory instances of the same node on disk. You can even have an alias of another in memory instance, as is sometimes required when creating higher level abstractions.

There isn't much interesting to do with a node, you can query its size, read from a specific location, get it's id and parent id, iterate over subnodes, etc. Most of the interesting things are done by higher level abstractions which are built on top of and know specifically how to interpret the bytes in a node - such as the heap, table, and property_bag.

See also
[MS-PST] 2.2.1.1

Definition at line 319 of file node.h.

Member Typedef Documentation

◆ subnode_iterator

A transform iterator, so we can expose the subnodes as a collection of nodes rather than subnode_info objects.

Definition at line 324 of file node.h.

Constructor & Destructor Documentation

◆ node() [1/6]

pstsdk::node::node ( 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 327 of file node.h.

◆ node() [2/6]

pstsdk::node::node ( const node 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 335 of file node.h.

◆ node() [3/6]

pstsdk::node::node ( 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 338 of file node.h.

◆ node() [4/6]

pstsdk::node::node ( const node other)
inline

Copy construct this node.

This node will be another instance of the specified node

Parameters
[in]otherThe node to copy

Definition at line 345 of file node.h.

◆ node() [5/6]

pstsdk::node::node ( const node other,
alias_tag   
)
inline

Alias constructor.

This node will be an alias of the specified node. They will refer to the same in memory object - they share a node_impl instance.

Parameters
[in]otherThe node to alias

Definition at line 353 of file node.h.

◆ node() [6/6]

pstsdk::node::node ( node &&  other)
inline

Move constructor.

Parameters
[in]otherNode to move from

Definition at line 359 of file node.h.

Member Function Documentation

◆ get_data_block()

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

Returns the data block associated with this node.

Returns
A shared pointer to the data block

Definition at line 380 of file node.h.

◆ get_data_id()

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

Get the block_id of the data block of this node.

Returns
The id

Definition at line 370 of file node.h.

◆ get_id()

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

Get the id of this node.

Returns
The id

Definition at line 368 of file node.h.

◆ get_page_count()

uint pstsdk::node::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 430 of file node.h.

◆ get_page_size()

size_t pstsdk::node::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 427 of file node.h.

◆ get_parent_id()

node_id pstsdk::node::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 375 of file node.h.

◆ get_sub_id()

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

Get the block_id of the subnode block of this node.

Returns
The id

Definition at line 372 of file node.h.

◆ get_subnode_block()

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

Returns the subnode block associated with this node.

Returns
A shared pointer to the subnode block

Definition at line 383 of file node.h.

◆ is_subnode()

bool pstsdk::node::is_subnode ( )
inline

Tells you if this is a subnode.

Returns
true if this is a subnode, false otherwise

Definition at line 377 of file node.h.

◆ lookup()

node pstsdk::node::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 461 of file node.h.

◆ open_as_stream()

node_stream_device pstsdk::node::open_as_stream ( )
inline

Creates a stream device over this node.

The returned stream device can be used to construct a proper stream:

node_stream nstream(n.open_as_stream());
Contains references to other bth_node allocations.
Definition heap.h:364
An in memory representation of the "node" concept in a PST data file.
Definition node.h:320
boost::iostreams::stream< node_stream_device > node_stream
The actual node stream, defined using the boost iostream library and the node_stream_device.
Definition node.h:294

Which can then be used as any iostream would be.

Returns
A node stream device for this node

Definition at line 421 of file node.h.

◆ operator=()

node & pstsdk::node::operator= ( const node 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 364 of file node.h.

◆ read() [1/4]

size_t pstsdk::node::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 393 of file node.h.

◆ read() [2/4]

size_t pstsdk::node::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 387 of file node.h.

◆ read() [3/4]

template<typename T >
T pstsdk::node::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 396 of file node.h.

◆ read() [4/4]

template<typename T >
T pstsdk::node::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 390 of file node.h.

◆ size()

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

Returns the size of this node.

Returns
The node size

Definition at line 425 of file node.h.

◆ subnode_begin()

subnode_iterator pstsdk::node::subnode_begin ( ) const
inline

Returns a proxy iterator for the first subnode.

This is known as a proxy iterator because the dereferenced type is of type node, not node& or const node&. This means the object is an rvalue, constructed specifically for the purpose of being returned from this iterator.

Returns
The proxy iterator

Definition at line 447 of file node.h.

◆ subnode_end()

subnode_iterator pstsdk::node::subnode_end ( ) const
inline

Returns a proxy iterator positioned past the last subnode.

This is known as a proxy iterator because the dereferenced type is of type node, not node& or const node&. This means the object is an rvalue, constructed specifically for the purpose of being returned from this iterator.

Returns
The proxy iterator

Definition at line 457 of file node.h.

◆ subnode_info_begin()

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

Returns an iterator positioned at first subnodeinfo.

Returns
An iterator over subnodeinfos

Definition at line 434 of file node.h.

◆ subnode_info_end()

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

Returns an iterator positioned past the last subnodeinfo.

Returns
An iterator over subnodeinfos

Definition at line 437 of file node.h.


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