blob: 511b55585ebd7536b1fa6b65c9d49cd0de92a526 [file] [log] [blame]
Aaron Smith89bca9e2017-11-16 14:33:09 +00001//===- 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
13using namespace llvm;
14using namespace llvm::pdb;
15
16DIAEnumTables::DIAEnumTables(
17 CComPtr<IDiaEnumTables> DiaEnumerator)
18 : Enumerator(DiaEnumerator) {}
19
20uint32_t DIAEnumTables::getChildCount() const {
21 LONG Count = 0;
22 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
23}
24
25std::unique_ptr<IPDBTable>
26DIAEnumTables::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
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
46void DIAEnumTables::reset() { Enumerator->Reset(); }
47
48DIAEnumTables *DIAEnumTables::clone() const {
49 CComPtr<IDiaEnumTables> EnumeratorClone;
50 if (S_OK != Enumerator->Clone(&EnumeratorClone))
51 return nullptr;
52 return new DIAEnumTables(EnumeratorClone);
53}