13#ifndef PSTSDK_LTP_OBJECT_H
14#define PSTSDK_LTP_OBJECT_H
21#include <boost/iostreams/concepts.hpp>
24#pragma warning(disable:4244)
26#include <boost/iostreams/stream.hpp>
62 std::streampos
seek(boost::iostreams::stream_offset
off, std::ios_base::seekdir
way)
75 std::streamsize m_pos;
81typedef boost::iostreams::stream<hnid_stream_device>
prop_stream;
191#pragma warning(suppress:4127)
193 if(!std::is_pod<T>::value)
194 throw std::invalid_argument(
"T must be a POD or one of the specialized classes");
199 return *(
reinterpret_cast<T*
>(&
t));
201 else if(
sizeof(T) ==
sizeof(
ulong))
204 return *(
reinterpret_cast<T*
>(&
t));
206 else if(
sizeof(T) ==
sizeof(
ushort))
209 return *(
reinterpret_cast<T*
>(&
t));
211 else if(
sizeof(T) ==
sizeof(
byte))
214 return *(
reinterpret_cast<T*
>(&
t));
219 return *(
reinterpret_cast<T*
>(&
buffer[0]));
227#pragma warning(suppress:4127)
229 if(!std::is_pod<T>::value)
230 throw std::invalid_argument(
"T must be a POD or one of the specialized classes");
232 std::vector<byte>
buffer = get_value_variable(
id);
233 return std::vector<T>(
reinterpret_cast<T*
>(&
buffer[0]),
reinterpret_cast<T*
>(&
buffer[0] +
buffer.size()));
240inline bool const_property_object::read_prop<bool>(
prop_id id)
const
246inline std::vector<bool> pstsdk::const_property_object::read_prop_array<bool>(
prop_id id)
const
248 using namespace std::placeholders;
259inline time_t const_property_object::read_time_t_prop(
prop_id id)
const
278inline std::vector<time_t> const_property_object::read_time_t_array(
prop_id id)
const
281inline std::vector<time_t> const_property_object::read_prop_array<time_t>(
prop_id id)
const
293 std::vector<ulonglong> time_values = read_prop_array<ulonglong>(
id);
294 std::vector<time_t> result(time_values.size());
295 std::transform(time_values.begin(), time_values.end(), result.begin(),
filetime_to_time_t);
302inline std::vector<byte> const_property_object::read_prop<std::vector<byte> >(
prop_id id)
const
304 return get_value_variable(
id);
318inline std::vector<std::vector<byte>> const_property_object::read_prop_array<std::vector<byte> >(
prop_id id)
const
320 std::vector<byte>
buffer = get_value_variable(
id);
321#ifdef PSTSDK_VALIDATION_LEVEL_WEAK
323 throw std::length_error(
"mv prop too short");
326 std::vector<std::vector<byte> >
results;
328#ifdef PSTSDK_VALIDATION_LEVEL_WEAK
330 throw std::length_error(
"mv prop too short");
337#ifdef PSTSDK_VALIDATION_LEVEL_WEAK
339 throw std::length_error(
"inconsistent mv prop toc");
348inline std::wstring const_property_object::read_prop<std::wstring>(
prop_id id)
const
350 std::vector<byte>
buffer = get_value_variable(
id);
364inline std::vector<std::wstring> const_property_object::read_prop_array<std::wstring>(
prop_id id)
const
366 std::vector<std::vector<byte> > buffer = read_prop_array<std::vector<byte> >(id);
367 std::vector<std::wstring> results;
369 for(
size_t i = 0; i < buffer.size(); ++i)
373 std::string s(buffer[i].begin(), buffer[i].end());
374 results.push_back(std::wstring(s.begin(), s.end()));
386inline std::string const_property_object::read_prop<std::string>(
prop_id id)
const
388 std::vector<byte>
buffer = get_value_variable(
id);
400 return std::string();
405inline std::vector<std::string> const_property_object::read_prop_array<std::string>(
prop_id id)
const
407 std::vector<std::vector<byte> > buffer = read_prop_array<std::vector<byte> >(id);
408 std::vector<std::string> results;
410 for(
size_t i = 0; i < buffer.size(); ++i)
414 results.push_back(std::string(buffer[i].begin(), buffer[i].end()));
421 results.push_back(std::string(s.begin(), s.end()));
423 results.push_back(std::string());
Contains references to other bth_node allocations.
const_iterator end() const
Returns a STL style iterator positioned at the "end" entry.
const_iterator begin() const
Returns a STL style iterator positioned at the first entry.
Property object base class.
virtual hnid_stream_device open_prop_stream(prop_id id)=0
Creates a stream device over a property on this object.
virtual ulong get_value_4(prop_id id) const =0
Implemented by child classes to fetch a 4 byte sized property.
std::optional< T > read_prop_if_exists(prop_id id) const
Read a property as a given type, if it exists.
virtual ushort get_value_2(prop_id id) const =0
Implemented by child classes to fetch a 2 byte sized property.
virtual std::vector< byte > get_value_variable(prop_id id) const =0
Implemented by child classes to fetch a variable sized property.
virtual bool prop_exists(prop_id id) const =0
Indicates the existance of a given property on this object.
T read_prop(prop_id id) const
Read a property as a given type.
virtual prop_type get_prop_type(prop_id id) const =0
Get the property type of a given prop_id.
virtual ~const_property_object()
virtual byte get_value_1(prop_id id) const =0
Implemented by child classes to fetch a 1 byte sized property.
virtual size_t size(prop_id id) const =0
Returns the total size of a variable length property.
virtual ulonglong get_value_8(prop_id id) const =0
Implemented by child classes to fetch a 8 byte sized property.
virtual std::vector< prop_id > get_prop_list() const =0
Get a list of all properties on this object.
std::vector< T > read_prop_array(prop_id id) const
Read a property as an array of the given type.
Defines a stream device for a heap allocation for use by boost iostream.
std::streampos seek(boost::iostreams::stream_offset off, std::ios_base::seekdir way)
Move the current position in the stream.
std::streamsize read(char *pbuffer, std::streamsize n)
Read data from this node into the buffer at the current position.
Defines a stream device which can wrap one of the two prop sources.
std::streamsize read(char *pbuffer, std::streamsize n)
Read data from this node into the buffer at the current position.
hnid_stream_device(const node_stream_device &node_device)
Wrap a node_stream_device.
hnid_stream_device(const hid_stream_device &hid_device)
Wrap a hid_stream_device.
std::streampos seek(boost::iostreams::stream_offset off, std::ios_base::seekdir way)
Move the current position in the stream.
Defines a stream device for a node for use by boost iostream.
std::streamsize read(char *pbuffer, std::streamsize n)
Read data from this node into the buffer at the current position.
std::streampos seek(boost::iostreams::stream_offset off, std::ios_base::seekdir way)
Move the current position in the stream.
The exceptions used by pstsdk.
boost::uint64_t ulonglong
prop_type
The different property types as defined by MAPI.
@ prop_type_apptime
VT_DATE.
time_t filetime_to_time_t(ulonglong filetime)
Convert from a filetime to time_t.
std::wstring bytes_to_wstring(const std::vector< byte > &bytes)
Convert an array of bytes to a std::wstring.
time_t vt_date_to_time_t(double vt_time)
Convert from a VT_DATE to a time_t.
std::string bytes_to_string(const std::vector< byte > &bytes)
Convert an array of bytes to a std::wstring.
Heap-on-Node (HN) and BTree-on-Heap (BTH) implementation.
Contains the definition of all in memory representations of disk structures.
Node and Block definitions.
Primitive structures defined by MS-PST and MAPI.
Multi-valued, variable length property TOC.
General utility functions and classes.