1 //===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H 11 #define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H 12 13 #include "llvm/ADT/Optional.h" 14 #include "llvm/ADT/StringMap.h" 15 #include "llvm/ADT/StringRef.h" 16 #include "llvm/ADT/iterator_range.h" 17 #include "llvm/DebugInfo/PDB/Native/HashTable.h" 18 #include "llvm/Support/Error.h" 19 #include <cstdint> 20 21 namespace llvm { 22 23 class BinaryStreamReader; 24 class BinaryStreamWriter; 25 26 namespace pdb { 27 28 class NamedStreamMap { 29 friend class NamedStreamMapBuilder; 30 31 struct FinalizationInfo { 32 uint32_t StringDataBytes = 0; 33 uint32_t SerializedLength = 0; 34 }; 35 36 public: 37 NamedStreamMap(); 38 39 Error load(BinaryStreamReader &Stream); 40 Error commit(BinaryStreamWriter &Writer) const; 41 uint32_t finalize(); 42 43 uint32_t size() const; 44 bool get(StringRef Stream, uint32_t &StreamNo) const; 45 void set(StringRef Stream, uint32_t StreamNo); 46 void remove(StringRef Stream); 47 const StringMap<uint32_t> &getStringMap() const { return Mapping; } 48 iterator_range<StringMapConstIterator<uint32_t>> entries() const; 49 50 private: 51 Optional<FinalizationInfo> FinalizedInfo; 52 HashTable FinalizedHashTable; 53 StringMap<uint32_t> Mapping; 54 }; 55 56 } // end namespace pdb 57 58 } // end namespace llvm 59 60 #endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H 61