1ff0cc061SDimitry Andric //==- DIAEnumDebugStreams.cpp - DIA Debug Stream Enumerator impl -*- C++ -*-==// 2ff0cc061SDimitry Andric // 3ff0cc061SDimitry Andric // The LLVM Compiler Infrastructure 4ff0cc061SDimitry Andric // 5ff0cc061SDimitry Andric // This file is distributed under the University of Illinois Open Source 6ff0cc061SDimitry Andric // License. See LICENSE.TXT for details. 7ff0cc061SDimitry Andric // 8ff0cc061SDimitry Andric //===----------------------------------------------------------------------===// 9ff0cc061SDimitry Andric 10ff0cc061SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h" 11db17bf38SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIADataStream.h" 12db17bf38SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbol.h" 13ff0cc061SDimitry Andric 14ff0cc061SDimitry Andric using namespace llvm; 153ca95b02SDimitry Andric using namespace llvm::pdb; 16ff0cc061SDimitry Andric DIAEnumDebugStreams(CComPtr<IDiaEnumDebugStreams> DiaEnumerator)17ff0cc061SDimitry AndricDIAEnumDebugStreams::DIAEnumDebugStreams( 18ff0cc061SDimitry Andric CComPtr<IDiaEnumDebugStreams> DiaEnumerator) 19ff0cc061SDimitry Andric : Enumerator(DiaEnumerator) {} 20ff0cc061SDimitry Andric getChildCount() const21ff0cc061SDimitry Andricuint32_t DIAEnumDebugStreams::getChildCount() const { 22ff0cc061SDimitry Andric LONG Count = 0; 23ff0cc061SDimitry Andric return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 24ff0cc061SDimitry Andric } 25ff0cc061SDimitry Andric 26ff0cc061SDimitry Andric std::unique_ptr<IPDBDataStream> getChildAtIndex(uint32_t Index) const27ff0cc061SDimitry AndricDIAEnumDebugStreams::getChildAtIndex(uint32_t Index) const { 28ff0cc061SDimitry Andric CComPtr<IDiaEnumDebugStreamData> Item; 29ff0cc061SDimitry Andric VARIANT VarIndex; 30ff0cc061SDimitry Andric VarIndex.vt = VT_I4; 31ff0cc061SDimitry Andric VarIndex.lVal = Index; 32ff0cc061SDimitry Andric if (S_OK != Enumerator->Item(VarIndex, &Item)) 33ff0cc061SDimitry Andric return nullptr; 34ff0cc061SDimitry Andric 35ff0cc061SDimitry Andric return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); 36ff0cc061SDimitry Andric } 37ff0cc061SDimitry Andric getNext()38ff0cc061SDimitry Andricstd::unique_ptr<IPDBDataStream> DIAEnumDebugStreams::getNext() { 39ff0cc061SDimitry Andric CComPtr<IDiaEnumDebugStreamData> Item; 40ff0cc061SDimitry Andric ULONG NumFetched = 0; 41ff0cc061SDimitry Andric if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) 42ff0cc061SDimitry Andric return nullptr; 43ff0cc061SDimitry Andric 44ff0cc061SDimitry Andric return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); 45ff0cc061SDimitry Andric } 46ff0cc061SDimitry Andric reset()47ff0cc061SDimitry Andricvoid DIAEnumDebugStreams::reset() { Enumerator->Reset(); } 48