1 //===- DIAEnumTables.cpp - DIA Table Enumerator Impl ------------*- 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 #include "llvm/DebugInfo/PDB/DIA/DIAEnumTables.h" 11 #include "llvm/DebugInfo/PDB/DIA/DIATable.h" 12 13 using namespace llvm; 14 using namespace llvm::pdb; 15 DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator)16DIAEnumTables::DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator) 17 : Enumerator(DiaEnumerator) {} 18 getChildCount() const19uint32_t DIAEnumTables::getChildCount() const { 20 LONG Count = 0; 21 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 22 } 23 24 std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const25DIAEnumTables::getChildAtIndex(uint32_t Index) const { 26 CComPtr<IDiaTable> Item; 27 VARIANT Var; 28 Var.vt = VT_UINT; 29 Var.uintVal = Index; 30 if (S_OK != Enumerator->Item(Var, &Item)) 31 return nullptr; 32 33 return std::unique_ptr<IPDBTable>(new DIATable(Item)); 34 } 35 getNext()36std::unique_ptr<IPDBTable> DIAEnumTables::getNext() { 37 CComPtr<IDiaTable> Item; 38 ULONG CeltFetched = 0; 39 if (S_OK != Enumerator->Next(1, &Item, &CeltFetched)) 40 return nullptr; 41 42 return std::unique_ptr<IPDBTable>(new DIATable(Item)); 43 } 44 reset()45void DIAEnumTables::reset() { Enumerator->Reset(); } 46