1317760Sdim//===- PDBStringTable.h - PDB String Table -----------------------*- C++-*-===//
2317760Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6317760Sdim//
7317760Sdim//===----------------------------------------------------------------------===//
8317760Sdim
9317760Sdim#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H
10317760Sdim#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H
11317760Sdim
12317760Sdim#include "llvm/ADT/ArrayRef.h"
13317760Sdim#include "llvm/ADT/StringRef.h"
14319250Sdim#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
15317760Sdim#include "llvm/Support/BinaryStreamArray.h"
16317760Sdim#include "llvm/Support/BinaryStreamRef.h"
17317760Sdim#include "llvm/Support/Endian.h"
18317760Sdim#include "llvm/Support/Error.h"
19317760Sdim#include <cstdint>
20317760Sdim#include <vector>
21317760Sdim
22317760Sdimnamespace llvm {
23317760Sdimclass BinaryStreamReader;
24317760Sdim
25317760Sdimnamespace msf {
26317760Sdimclass MappedBlockStream;
27317760Sdim}
28317760Sdim
29317760Sdimnamespace pdb {
30317760Sdim
31317760Sdimstruct PDBStringTableHeader;
32317760Sdim
33317760Sdimclass PDBStringTable {
34317760Sdimpublic:
35317760Sdim  Error reload(BinaryStreamReader &Reader);
36317760Sdim
37317760Sdim  uint32_t getByteSize() const;
38317760Sdim  uint32_t getNameCount() const;
39317760Sdim  uint32_t getHashVersion() const;
40317760Sdim  uint32_t getSignature() const;
41317760Sdim
42317760Sdim  Expected<StringRef> getStringForID(uint32_t ID) const;
43317760Sdim  Expected<uint32_t> getIDForString(StringRef Str) const;
44317760Sdim
45317760Sdim  FixedStreamArray<support::ulittle32_t> name_ids() const;
46317760Sdim
47320041Sdim  const codeview::DebugStringTableSubsectionRef &getStringTable() const;
48319547Sdim
49317760Sdimprivate:
50317760Sdim  Error readHeader(BinaryStreamReader &Reader);
51317760Sdim  Error readStrings(BinaryStreamReader &Reader);
52317760Sdim  Error readHashTable(BinaryStreamReader &Reader);
53317760Sdim  Error readEpilogue(BinaryStreamReader &Reader);
54317760Sdim
55317760Sdim  const PDBStringTableHeader *Header = nullptr;
56319250Sdim  codeview::DebugStringTableSubsectionRef Strings;
57317760Sdim  FixedStreamArray<support::ulittle32_t> IDs;
58317760Sdim  uint32_t NameCount = 0;
59317760Sdim};
60317760Sdim
61317760Sdim} // end namespace pdb
62317760Sdim} // end namespace llvm
63317760Sdim
64317760Sdim#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H
65