1 //===- DIADataStream.cpp - DIA implementation of IPDBDataStream -*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
10 #include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
13 using namespace llvm::pdb
;
15 DIADataStream::DIADataStream(CComPtr
<IDiaEnumDebugStreamData
> DiaStreamData
)
16 : StreamData(DiaStreamData
) {}
18 uint32_t DIADataStream::getRecordCount() const {
20 return (S_OK
== StreamData
->get_Count(&Count
)) ? Count
: 0;
23 std::string
DIADataStream::getName() const {
24 return invokeBstrMethod(*StreamData
, &IDiaEnumDebugStreamData::get_name
);
27 std::optional
<DIADataStream::RecordType
>
28 DIADataStream::getItemAtIndex(uint32_t Index
) const {
31 StreamData
->Item(Index
, 0, &RecordSize
, nullptr);
35 Record
.resize(RecordSize
);
36 if (S_OK
!= StreamData
->Item(Index
, RecordSize
, &RecordSize
, &Record
[0]))
41 bool DIADataStream::getNext(RecordType
&Record
) {
44 ULONG CountFetched
= 0;
45 StreamData
->Next(1, 0, &RecordSize
, nullptr, &CountFetched
);
49 Record
.resize(RecordSize
);
51 StreamData
->Next(1, RecordSize
, &RecordSize
, &Record
[0], &CountFetched
))
56 void DIADataStream::reset() { StreamData
->Reset(); }