aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/raw_pdb/src/PDB_IPIStream.h
blob: 0efdbe22a0a0279fe0c5dd7aa25d101aa96945e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2011-2022, Molecular Matters GmbH <[email protected]>
// See LICENSE.txt for licensing details (2-clause BSD License: https://opensource.org/licenses/BSD-2-Clause)

#pragma once

#include "Foundation/PDB_Macros.h"
#include "Foundation/PDB_ArrayView.h"
#include "PDB_ErrorCodes.h"
#include "PDB_IPITypes.h"
#include "PDB_CoalescedMSFStream.h"


// PDB IPI stream
// https://llvm.org/docs/PDB/TpiStream.html
namespace PDB
{
	class RawFile;


	class PDB_NO_DISCARD IPIStream
	{
	public:
		IPIStream(void) PDB_NO_EXCEPT;
		IPIStream(IPIStream&& other) PDB_NO_EXCEPT;
		IPIStream& operator=(IPIStream&& other) PDB_NO_EXCEPT;

		explicit IPIStream(const RawFile& file, const IPI::StreamHeader& header) PDB_NO_EXCEPT;
		~IPIStream(void) PDB_NO_EXCEPT;

		// Returns the index of the first type, which is not necessarily zero.
		PDB_NO_DISCARD inline uint32_t GetFirstTypeIndex(void) const PDB_NO_EXCEPT
		{
			return m_header.typeIndexBegin;
		}

		// Returns the index of the last type.
		PDB_NO_DISCARD inline uint32_t GetLastTypeIndex(void) const PDB_NO_EXCEPT
		{
			return m_header.typeIndexEnd;
		}

		// Returns a view of all type records.
		// Records identified by a type index can be accessed via "allRecords[typeIndex - firstTypeIndex]".
		PDB_NO_DISCARD inline ArrayView<const CodeView::IPI::Record*> GetTypeRecords(void) const PDB_NO_EXCEPT
		{
			return ArrayView<const CodeView::IPI::Record*>(m_records, m_recordCount);
		}

	private:
		IPI::StreamHeader m_header;
		CoalescedMSFStream m_stream;
		const CodeView::IPI::Record** m_records;
		size_t m_recordCount;

		PDB_DISABLE_COPY(IPIStream);
	};


	// ------------------------------------------------------------------------------------------------
	// General
	// ------------------------------------------------------------------------------------------------

	PDB_NO_DISCARD ErrorCode HasValidIPIStream(const RawFile& file) PDB_NO_EXCEPT;

	PDB_NO_DISCARD IPIStream CreateIPIStream(const RawFile& file) PDB_NO_EXCEPT;
}