blob: 4b72089c6ba2ec314bb5a92f04160b5540894c89 [file] [log] [blame]
Pavel Labathe0d51842017-11-01 15:52:08 +00001//===-- LibCxxQueue.cpp -----------------------------------------*- 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
Pavel Labathe0d51842017-11-01 15:52:08 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "LibCxx.h"
10#include "lldb/DataFormatters/FormattersHelpers.h"
11
12using namespace lldb;
13using namespace lldb_private;
14
15namespace {
16
17class QueueFrontEnd : public SyntheticChildrenFrontEnd {
18public:
19 QueueFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {
20 Update();
21 }
22
Adrian Prantl0e4c4822019-03-06 21:22:25 +000023 size_t GetIndexOfChildWithName(ConstString name) override {
Pavel Labathe0d51842017-11-01 15:52:08 +000024 return m_container_sp ? m_container_sp->GetIndexOfChildWithName(name)
25 : UINT32_MAX;
26 }
27
28 bool MightHaveChildren() override { return true; }
29 bool Update() override;
30
31 size_t CalculateNumChildren() override {
32 return m_container_sp ? m_container_sp->GetNumChildren() : 0;
33 }
34
35 ValueObjectSP GetChildAtIndex(size_t idx) override {
36 return m_container_sp ? m_container_sp->GetChildAtIndex(idx, true)
37 : nullptr;
38 }
39
40private:
41 ValueObjectSP m_container_sp;
42};
43} // namespace
44
45bool QueueFrontEnd::Update() {
46 m_container_sp.reset();
47 ValueObjectSP c_sp = m_backend.GetChildMemberWithName(ConstString("c"), true);
48 if (!c_sp)
49 return false;
50 m_container_sp = c_sp->GetSyntheticValue();
51 return false;
52}
53
54SyntheticChildrenFrontEnd *
55formatters::LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
56 lldb::ValueObjectSP valobj_sp) {
57 if (valobj_sp)
58 return new QueueFrontEnd(*valobj_sp);
59 return nullptr;
60}