blob: 7017f2600e9b9192a9902ad2ab517ae085d72e5f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- IPDBEnumChildren.h - base interface for child enumerator -*- 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#ifndef LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H
11#define LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H
12
Andrew Scull0372a572018-11-16 15:47:06 +000013#include <cassert>
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010014#include <cstdint>
15#include <memory>
16
17namespace llvm {
18namespace pdb {
19
20template <typename ChildType> class IPDBEnumChildren {
21public:
22 using ChildTypePtr = std::unique_ptr<ChildType>;
23 using MyType = IPDBEnumChildren<ChildType>;
24
25 virtual ~IPDBEnumChildren() = default;
26
27 virtual uint32_t getChildCount() const = 0;
28 virtual ChildTypePtr getChildAtIndex(uint32_t Index) const = 0;
29 virtual ChildTypePtr getNext() = 0;
30 virtual void reset() = 0;
Andrew Scull0372a572018-11-16 15:47:06 +000031};
32
33template <typename ChildType>
34class NullEnumerator : public IPDBEnumChildren<ChildType> {
35 virtual uint32_t getChildCount() const override { return 0; }
36 virtual std::unique_ptr<ChildType>
37 getChildAtIndex(uint32_t Index) const override {
38 return nullptr;
39 }
40 virtual std::unique_ptr<ChildType> getNext() override {
41 return nullptr;
42 }
43 virtual void reset() override {}
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010044};
45
46} // end namespace pdb
47} // end namespace llvm
48
49#endif // LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H