PST File Format SDK v0.4
Loading...
Searching...
No Matches
pst.h
Go to the documentation of this file.
1
12
13#ifndef PSTSDK_PST_PST_H
14#define PSTSDK_PST_PST_H
15
16#include <boost/noncopyable.hpp>
17#include <boost/iterator/filter_iterator.hpp>
18#include <boost/iterator/transform_iterator.hpp>
19
20#include "pstsdk/ndb/database.h"
22#include "pstsdk/ndb/node.h"
23
24#include "pstsdk/ltp/propbag.h"
25#include "pstsdk/ltp/nameid.h"
26
27#include "pstsdk/pst/folder.h"
28#include "pstsdk/pst/message.h"
30
31namespace pstsdk
32{
33
36
48class pst : private boost::noncopyable
49{
50public:
51 typedef boost::filter_iterator<is_nid_type<nid_type_folder>, const_nodeinfo_iterator> folder_filter_iterator;
52 typedef boost::filter_iterator<is_nid_type<nid_type_message>, const_nodeinfo_iterator> message_filter_iterator;
54 typedef boost::transform_iterator<message_transform_info, message_filter_iterator> message_iterator;
56 typedef boost::transform_iterator<folder_transform_info, folder_filter_iterator> folder_iterator;
57
60 pst(const std::wstring& filename)
61 : m_db(open_database(filename)) { }
62
65 pst(std::shared_ptr<file> custom_file)
66 : m_db(open_database(custom_file)) { }
67
73 : m_db(open_database(other_pst.m_db)) { }
74
75#ifndef BOOST_NO_RVALUE_REFERENCES
79 : m_db(std::move(other.m_db)), m_bag(std::move(other.m_bag)), m_map(std::move(other.m_map)) { }
80#endif
81
82 // subobject discovery/enumeration
86 { return boost::make_transform_iterator(boost::make_filter_iterator<is_nid_type<nid_type_folder> >(m_db->read_nbt_root()->begin(), m_db->read_nbt_root()->end()), folder_transform_info(m_db) ); }
90 { return boost::make_transform_iterator(boost::make_filter_iterator<is_nid_type<nid_type_folder> >(m_db->read_nbt_root()->end(), m_db->read_nbt_root()->end()), folder_transform_info(m_db) ); }
91
95 { return boost::make_filter_iterator<is_nid_type<nid_type_folder> >(m_db->read_nbt_root()->begin(), m_db->read_nbt_root()->end()); }
99 { return boost::make_filter_iterator<is_nid_type<nid_type_folder> >(m_db->read_nbt_root()->end(), m_db->read_nbt_root()->end()); }
100
104 { return boost::make_filter_iterator<is_nid_type<nid_type_message> >(m_db->read_nbt_root()->begin(), m_db->read_nbt_root()->end()); }
108 { return boost::make_filter_iterator<is_nid_type<nid_type_message> >(m_db->read_nbt_root()->end(), m_db->read_nbt_root()->end()); }
109
113 { return boost::make_transform_iterator(boost::make_filter_iterator<is_nid_type<nid_type_message> >(m_db->read_nbt_root()->begin(), m_db->read_nbt_root()->end()), message_transform_info(m_db) ); }
117 { return boost::make_transform_iterator(boost::make_filter_iterator<is_nid_type<nid_type_message> >(m_db->read_nbt_root()->end(), m_db->read_nbt_root()->end()), message_transform_info(m_db) ); }
118
123 { return folder(m_db, m_db->lookup_node(nid_root_folder)); }
128 folder open_folder(const std::wstring& name) const;
129
135 { return folder(m_db, m_db->lookup_node(id)); }
136
142 { return search_folder(m_db, m_db->lookup_node(id)); }
143
149 { return message(m_db->lookup_node(id)); }
150
151 // property access
154 std::wstring get_name() const
155 { return get_property_bag().read_prop<std::wstring>(PR_DISPLAY_NAME_W); }
160 prop_id lookup_prop_id(const guid& g, const std::wstring& name) const
161 { return get_name_id_map().lookup(g, name); }
166 prop_id lookup_prop_id(const guid& g, long id) const
167 { return get_name_id_map().lookup(g, id); }
178
179 // lower layer access
188 const property_bag& get_property_bag() const;
191 const name_id_map& get_name_id_map() const;
195 { return m_db; }
196
197private:
198 shared_db_ptr m_db;
199 mutable std::shared_ptr<property_bag> m_bag;
200 mutable std::shared_ptr<name_id_map> m_map;
201};
202
203} // end pstsdk namespace
204
206{
207 if(!m_bag)
208 m_bag.reset(new property_bag(m_db->lookup_node(nid_message_store)));
209
210 return *m_bag;
211}
212
214{
215 return const_cast<property_bag&>(const_cast<const pst*>(this)->get_property_bag());
216}
217
219{
220 if(!m_map)
221 m_map.reset(new name_id_map(m_db));
222
223 return *m_map;
224}
225
227{
228 return const_cast<name_id_map&>(const_cast<const pst*>(this)->get_name_id_map());
229}
230
231inline pstsdk::folder pstsdk::pst::open_folder(const std::wstring& name) const
232{
233 folder_iterator iter = std::find_if(folder_begin(), folder_end(), compiler_workarounds::folder_name_equal(name));
234
235 if(iter != folder_end())
236 return *iter;
237
239}
240
241#endif
Contains references to other bth_node allocations.
Definition heap.h:364
T read_prop(prop_id id) const
Read a property as a given type.
Definition object.h:188
Defines a transform from a node_info to a folder.
Definition folder.h:322
A folder in a PST file.
Definition folder.h:191
Represents a message in a PST file.
Definition message.h:229
A named property map abstraction.
Definition nameid.h:76
prop_id lookup(const guid &g, const std::wstring &name) const
Get the associated prop_id of the named property.
Definition nameid.h:118
A named property.
Definition nameid.h:31
Property Context (PC) Implementation.
Definition propbag.h:41
A PST file.
Definition pst.h:49
search_folder open_search_folder(node_id id) const
Open a specific message in this file.
Definition pst.h:141
prop_id lookup_prop_id(const guid &g, const std::wstring &name) const
Lookup a prop_id of a named prop.
Definition pst.h:160
shared_db_ptr get_db() const
Get the shared database pointer used by this object.
Definition pst.h:194
folder_iterator folder_begin() const
Get an iterator to the first folder in the PST file.
Definition pst.h:85
folder_filter_iterator folder_node_end() const
Get the end folder iterator.
Definition pst.h:98
folder open_folder(const std::wstring &name) const
Open a specific folder in this file.
Definition pst.h:231
property_bag & get_property_bag()
Get the property bag of the store object.
Definition pst.h:213
named_prop lookup_name_prop(prop_id id) const
Lookup a named prop of a prop_id.
Definition pst.h:176
message_filter_iterator message_node_end() const
Get the end message iterator.
Definition pst.h:107
prop_id lookup_prop_id(const guid &g, long id) const
Lookup a prop_id of a named prop.
Definition pst.h:166
boost::filter_iterator< is_nid_type< nid_type_message >, const_nodeinfo_iterator > message_filter_iterator
Definition pst.h:52
pst(const pstsdk::pst &other_pst)
Construct a pst object from another pst instance, copying its header and skipping validation.
Definition pst.h:72
pst(const std::wstring &filename)
Construct a pst object from the specified file.
Definition pst.h:60
pst(pst &&other)
Move constructor.
Definition pst.h:78
prop_id lookup_prop_id(const named_prop &n)
Lookup a prop_id of a named prop.
Definition pst.h:171
folder_iterator folder_end() const
Get the end folder iterator.
Definition pst.h:89
name_id_map & get_name_id_map()
Get the named prop map for this store.
Definition pst.h:226
folder_filter_iterator folder_node_begin() const
Get an iterator to the first folder in the PST file.
Definition pst.h:94
boost::transform_iterator< message_transform_info, message_filter_iterator > message_iterator
Message iterator type; a transform iterator over a filter iterator over a nodeinfo iterator.
Definition pst.h:54
message open_message(node_id id) const
Open a specific message in this file.
Definition pst.h:148
boost::transform_iterator< folder_transform_info, folder_filter_iterator > folder_iterator
Folder iterator type; a transform iterator over a filter iterator over a nodeinfo iterator.
Definition pst.h:56
folder open_root_folder() const
Opens the root folder of this file.
Definition pst.h:122
folder open_folder(node_id id) const
Open a specific message in this file.
Definition pst.h:134
message_iterator message_begin() const
Get an iterator to the first message in the PST file.
Definition pst.h:112
message_iterator message_end() const
Get the end message iterator.
Definition pst.h:116
message_filter_iterator message_node_begin() const
Get an iterator to the first message in the PST file.
Definition pst.h:103
pst(std::shared_ptr< file > custom_file)
Construct a pst object from a custom file instance.
Definition pst.h:65
boost::filter_iterator< is_nid_type< nid_type_folder >, const_nodeinfo_iterator > folder_filter_iterator
Definition pst.h:51
std::wstring get_name() const
Get the display name of the PST.
Definition pst.h:154
Search Folder object.
Definition folder.h:63
Database implementation.
Database interface.
Folder objects.
shared_db_ptr open_database(const std::wstring &filename)
Open a db_context for the given file.
Definition database.h:260
ulong node_id
Definition primitives.h:86
ushort prop_id
Definition primitives.h:93
@ nid_message_store
The property bag for this file.
Definition primitives.h:171
@ nid_root_folder
Root folder of the store.
Definition primitives.h:175
#define PR_DISPLAY_NAME_W
Definition mapitags.h:359
Message related classes.
Named Property Lookup Map implementation.
Contains the definition of all in memory representations of disk structures.
Definition disk.h:19
std::shared_ptr< db_context > shared_db_ptr
Node and Block definitions.
Primitive structures defined by MS-PST and MAPI.
Property Bag (or Property Context, or PC) implementation.
A Win32 GUID structure.
Definition primitives.h:353