Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
atomcontext.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QDOC_IR_ATOMCONTEXT_H
5#define QDOC_IR_ATOMCONTEXT_H
6
7#include <QJsonObject>
8#include <QList>
9
10#include <utility>
11
12QT_BEGIN_NAMESPACE
13
14namespace IR {
15
17{
41
46
47 void push(ContextType type, QJsonObject attrs = {})
48 {
49 m_stack.append(Frame{ type, std::move(attrs) });
50 }
51
53 {
54 Q_ASSERT(!m_stack.isEmpty());
55 return m_stack.takeLast();
56 }
57
58 [[nodiscard]] bool isInContext(ContextType type) const
59 {
60 for (auto it = m_stack.crbegin(); it != m_stack.crend(); ++it) {
61 if (it->type == type)
62 return true;
63 }
64 return false;
65 }
66
67 [[nodiscard]] const Frame &current() const
68 {
69 Q_ASSERT(!m_stack.isEmpty());
70 return m_stack.constLast();
71 }
72
73 [[nodiscard]] bool isEmpty() const { return m_stack.isEmpty(); }
74
75 [[nodiscard]] qsizetype depth() const { return m_stack.size(); }
76
77 void clear() { m_stack.clear(); }
78
79private:
80 QList<Frame> m_stack;
81};
82
83} // namespace IR
84
85QT_END_NAMESPACE
86
87#endif // QDOC_IR_ATOMCONTEXT_H
Definition builder.cpp:14
bool isInContext(ContextType type) const
Definition atomcontext.h:58
const Frame & current() const
Definition atomcontext.h:67
bool isEmpty() const
Definition atomcontext.h:73
qsizetype depth() const
Definition atomcontext.h:75
void push(ContextType type, QJsonObject attrs={})
Definition atomcontext.h:47