KTextTemplate

rendercontext.cpp
1/*
2 This file is part of the KTextTemplate library
3
4 SPDX-FileCopyrightText: 2010 Stephen Kelly <steveire@gmail.com>
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7
8*/
9
10#include "rendercontext.h"
11
12#include "node.h"
13
14using namespace KTextTemplate;
15
16namespace KTextTemplate
17{
18
19class RenderContextPrivate
20{
21 RenderContextPrivate(RenderContext *qq)
22 : q_ptr(qq)
23 {
24 }
25
26 Q_DECLARE_PUBLIC(RenderContext)
27 RenderContext *const q_ptr;
28
29 QList<QHash<const Node *, QVariant>> m_variantHashStack;
30};
31}
32
33RenderContext::RenderContext()
34 : d_ptr(new RenderContextPrivate(this))
35{
36}
37
39{
40 delete d_ptr;
41}
42
43void RenderContext::push()
44{
46 d->m_variantHashStack.prepend({});
47}
48
49bool RenderContext::contains(Node *const scopeNode) const
50{
51 Q_D(const RenderContext);
52 Q_ASSERT(!d->m_variantHashStack.isEmpty());
53 return d->m_variantHashStack.last().contains(scopeNode);
54}
55
56QVariant &RenderContext::data(const Node *const scopeNode)
57{
59 Q_ASSERT(!d->m_variantHashStack.isEmpty());
60 return d->m_variantHashStack.last()[scopeNode];
61}
62
63void RenderContext::pop()
64{
66 d->m_variantHashStack.removeFirst();
67}
Base class for all nodes.
Definition node.h:72
Provides storage facility for state while rendering a template.
bool contains(Node *const scopeNode) const
Returns whether the RenderContext contains data for scopeNode.
QVariant & data(const Node *const scopeNode)
Returns the data for the node scopeNode.
The KTextTemplate namespace holds all public KTextTemplate API.
Definition Mainpage.dox:8
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Apr 27 2024 22:14:09 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.