6#ifndef PSTSDK_LTP_NAMEID_H
7#define PSTSDK_LTP_NAMEID_H
37 : m_guid(
g), m_is_string(
false), m_id(id) { }
42 : m_guid(
g), m_is_string(
true), m_name(
name) { }
57 const std::wstring&
get_name()
const {
return m_name; }
83 : m_bag(
db->lookup_node(
nid_name_id_map)), m_buckets(m_bag.read_prop<
slong>(0x1)), m_entry_stream(m_bag.open_prop_stream(0x3)), m_guid_stream(m_bag.open_prop_stream(0x2)), m_string_stream(m_bag.open_prop_stream(0x4)) { }
149 std::wstring read_wstring(
ulong string_offset)
const;
154 {
return static_cast<prop_id>((hash_value % m_buckets) + 0x1000); }
163inline pstsdk::named_prop pstsdk::name_id_map::construct(
const disk::nameid& entry)
const
174 m_entry_stream.seekg(index *
sizeof(disk::nameid), std::ios_base::beg);
175 m_entry_stream.read((
char*)&entry,
sizeof(entry));
176 return construct(entry);
189 m_guid_stream.seekg((guid_index-3) *
sizeof(guid), std::ios_base::beg);
190 m_guid_stream.read((
char*)&g,
sizeof(g));
194inline pstsdk::ushort pstsdk::name_id_map::get_guid_index(
const guid& g)
const
196 if(memcmp(&g, &
ps_none,
sizeof(g)) == 0)
198 if(memcmp(&g, &
ps_mapi,
sizeof(g)) == 0)
205 m_guid_stream.seekg(0, std::ios_base::beg);
206 while(m_guid_stream.read((
char*)&g_disk,
sizeof(g_disk)))
208 if(memcmp(&g, &g_disk,
sizeof(g)) == 0)
214 m_guid_stream.clear();
215 throw key_not_found<guid>(g);
218inline std::wstring pstsdk::name_id_map::read_wstring(
ulong string_offset)
const
220 m_string_stream.seekg(string_offset, std::ios_base::beg);
223 m_string_stream.read((
char*)&size,
sizeof(size));
225 std::vector<byte> buffer(size);
226 m_string_stream.read(
reinterpret_cast<char *
>(&buffer[0]), size);
231inline pstsdk::ulong pstsdk::name_id_map::compute_hash_base(
const named_prop& n)
const {
250 catch(std::exception&)
259 return static_cast<size_t>((
id - 0x8000)) < get_prop_count();
268 std::vector<prop_id>
props;
270 m_entry_stream.seekg(0, std::ios_base::beg);
271 while(m_entry_stream.read((
char*)&entry,
sizeof(entry)))
272 props.push_back(nameid_get_prop_index(entry) + 0x8000);
274 m_entry_stream.clear();
281 m_entry_stream.seekg(0, std::ios_base::end);
283 return static_cast<size_t>(m_entry_stream.tellg()) /
sizeof(
disk::nameid);
308 ulong hash_base = compute_hash_base(
p);
310 if(!m_bag.prop_exists(get_bucket_prop(
hash_value)))
315 while(
bucket.read((
char*)&entry,
sizeof(entry)))
342 ulong index =
id - 0x8000;
344 if(index > get_prop_count())
347 return construct(index);
heap_id get_id() const
Return the heap_id of this bth_node.
Contains references to other bth_node allocations.
A named property map abstraction.
prop_id lookup(const guid &g, long id) const
Get the associated prop_id of the named property.
std::vector< prop_id > get_prop_list() const
Get all of the prop_ids which have a named_prop mapping in this store.
name_id_map(const shared_db_ptr &db)
Construct a name_id_map for the given store.
bool id_exists(const guid &g, long id) const
Query if a given named prop exists.
bool named_prop_exists(const named_prop &p) const
Query if a given named prop exists.
prop_id lookup(const guid &g, const std::wstring &name) const
Get the associated prop_id of the named property.
size_t get_prop_count() const
Get the total count of named property mappings in this store.
bool name_exists(const guid &g, const std::wstring &name) const
Query if a given named prop exists.
bool prop_id_exists(prop_id id) const
Query if a given prop_id has a named_prop mapped to it.
long get_id() const
Get the numerical id of this property.
const guid & get_guid() const
Get the namespace GUID of which this named prop is a member.
bool is_string() const
Return true if this is a string named prop.
const std::wstring & get_name() const
Get the name of this property.
named_prop(const guid &g, long id)
Construct a named prop from a guid and an id.
named_prop(const guid &g, const std::wstring &name)
Construct a named prop from a guid and a string.
const guid ps_public_strings
The PS_PUBLIC_STRINGS guid.
const guid ps_none
The NULL guid.
const guid ps_mapi
The PS_MAPI guid.
@ nid_name_id_map
Contains the named prop mappings.
std::wstring bytes_to_wstring(const std::vector< byte > &bytes)
Convert an array of bytes to a std::wstring.
std::vector< byte > wstring_to_bytes(const std::wstring &wstr)
Convert a std::wstring to an array of bytes.
Contains the definition of all in memory representations of disk structures.
std::shared_ptr< db_context > shared_db_ptr
Primitive structures defined by MS-PST and MAPI.
Property Bag (or Property Context, or PC) implementation.
A modified nameid structure used in the hash buckets.
ulong hash_base
For numeric named props, this is just the id. Hash value of string props.
Defines a id to name mapping.