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( 17 CComPtr<IDiaEnumTables> DiaEnumerator) 18 : Enumerator(DiaEnumerator) {} 19 getChildCount() const20uint32_t DIAEnumTables::getChildCount() const { 21 LONG Count = 0; 22 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 23 } 24 25 std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const26DIAEnumTables::getChildAtIndex(uint32_t Index) const { 27 CComPtr<IDiaTable> Item; 28 VARIANT Var; 29 Var.vt = VT_UINT; 30 Var.uintVal = Index; 31 if (S_OK != Enumerator->Item(Var, &Item)) 32 return nullptr; 33 34 return std::unique_ptr<IPDBTable>(new DIATable(Item)); 35 } 36 getNext()37std::unique_ptr<IPDBTable> DIAEnumTables::getNext() { 38 CComPtr<IDiaTable> Item; 39 ULONG CeltFetched = 0; 40 if (S_OK != Enumerator->Next(1, &Item, &CeltFetched)) 41 return nullptr; 42 43 return std::unique_ptr<IPDBTable>(new DIATable(Item)); 44 } 45 reset()46void DIAEnumTables::reset() { Enumerator->Reset(); } 47 clone() const48DIAEnumTables *DIAEnumTables::clone() const { 49 CComPtr<IDiaEnumTables> EnumeratorClone; 50 if (S_OK != Enumerator->Clone(&EnumeratorClone)) 51 return nullptr; 52 return new DIAEnumTables(EnumeratorClone); 53 } 54