blob: e4cb4daf94b1453e9613c1be8431dbb8dd395c13 [file] [log] [blame]
Zachary Turnercffff262015-02-10 21:17:52 +00001//==- DIAEnumDebugStreams.cpp - DIA Debug Stream Enumerator impl -*- C++ -*-==//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Zachary Turnercffff262015-02-10 21:17:52 +00006//
7//===----------------------------------------------------------------------===//
8
Chandler Carruth71f308a2015-02-13 09:09:03 +00009#include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000010#include "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
11#include "llvm/DebugInfo/PDB/PDBSymbol.h"
Zachary Turnercffff262015-02-10 21:17:52 +000012
13using namespace llvm;
Zachary Turnerec28fc32016-05-04 20:32:13 +000014using namespace llvm::pdb;
Zachary Turnercffff262015-02-10 21:17:52 +000015
16DIAEnumDebugStreams::DIAEnumDebugStreams(
17 CComPtr<IDiaEnumDebugStreams> DiaEnumerator)
18 : Enumerator(DiaEnumerator) {}
19
20uint32_t DIAEnumDebugStreams::getChildCount() const {
21 LONG Count = 0;
22 return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
23}
24
25std::unique_ptr<IPDBDataStream>
26DIAEnumDebugStreams::getChildAtIndex(uint32_t Index) const {
27 CComPtr<IDiaEnumDebugStreamData> Item;
28 VARIANT VarIndex;
29 VarIndex.vt = VT_I4;
30 VarIndex.lVal = Index;
31 if (S_OK != Enumerator->Item(VarIndex, &Item))
32 return nullptr;
33
34 return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item));
35}
36
37std::unique_ptr<IPDBDataStream> DIAEnumDebugStreams::getNext() {
38 CComPtr<IDiaEnumDebugStreamData> Item;
39 ULONG NumFetched = 0;
40 if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
41 return nullptr;
42
43 return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item));
44}
45
46void DIAEnumDebugStreams::reset() { Enumerator->Reset(); }