Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 1 | //==- DIAEnumSourceFiles.cpp - DIA Source File Enumerator impl ---*- C++ -*-==// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h" |
| 10 | #include "llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h" |
| 11 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 12 | |
| 13 | using namespace llvm; |
| 14 | using namespace llvm::pdb; |
| 15 | |
| 16 | DIAEnumInjectedSources::DIAEnumInjectedSources( |
Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 17 | CComPtr<IDiaEnumInjectedSources> DiaEnumerator) |
Reid Kleckner | ba732f2 | 2018-09-14 20:16:31 +0000 | [diff] [blame] | 18 | : Enumerator(DiaEnumerator) {} |
Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 19 | |
| 20 | uint32_t DIAEnumInjectedSources::getChildCount() const { |
| 21 | LONG Count = 0; |
| 22 | return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; |
| 23 | } |
| 24 | |
| 25 | std::unique_ptr<IPDBInjectedSource> |
| 26 | DIAEnumInjectedSources::getChildAtIndex(uint32_t Index) const { |
| 27 | CComPtr<IDiaInjectedSource> Item; |
| 28 | if (S_OK != Enumerator->Item(Index, &Item)) |
| 29 | return nullptr; |
| 30 | |
Reid Kleckner | 8562c1a | 2018-03-21 21:47:26 +0000 | [diff] [blame] | 31 | return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item)); |
Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() { |
| 35 | CComPtr<IDiaInjectedSource> Item; |
| 36 | ULONG NumFetched = 0; |
| 37 | if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) |
| 38 | return nullptr; |
| 39 | |
Reid Kleckner | 8562c1a | 2018-03-21 21:47:26 +0000 | [diff] [blame] | 40 | return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item)); |
Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void DIAEnumInjectedSources::reset() { Enumerator->Reset(); } |