File indexing completed on 2025-02-09 04:28:39

0001 /*
0002   This file is part of the KTextTemplate library
0003 
0004   SPDX-FileCopyrightText: 2010 Stephen Kelly <steveire@gmail.com>
0005 
0006   SPDX-License-Identifier: LGPL-2.1-or-later
0007 
0008 */
0009 
0010 #ifndef KTEXTTEMPLATE_RENDERCONTEXT_H
0011 #define KTEXTTEMPLATE_RENDERCONTEXT_H
0012 
0013 #include "ktexttemplate_export.h"
0014 
0015 #include <QVariantHash>
0016 
0017 /// @headerfile rendercontext.h <KTextTemplate/RenderContext>
0018 
0019 namespace KTextTemplate
0020 {
0021 
0022 class ContextPrivate;
0023 class TemplateImpl;
0024 class Node;
0025 
0026 class RenderContextPrivate;
0027 
0028 /**
0029    @brief Provides storage facility for state while rendering a template.
0030 
0031    This class can not be instatiated by users of it. An instance
0032    of **%RenderContext** is available through Context::renderContext() for use
0033    with implementations of re-entrant template tags.
0034  */
0035 class KTEXTTEMPLATE_EXPORT RenderContext
0036 {
0037 public:
0038     /**
0039       Returns the data for the node @p scopeNode.
0040      */
0041     QVariant &data(const Node *const scopeNode);
0042 
0043     /**
0044       Returns whether the **%RenderContext** contains data for @p scopeNode.
0045      */
0046     bool contains(Node *const scopeNode) const;
0047 
0048     /**
0049       Destructor
0050      */
0051     ~RenderContext();
0052 
0053 #ifndef K_DOXYGEN
0054 private:
0055     RenderContext();
0056 
0057     void push();
0058 
0059     void pop();
0060 
0061 private:
0062     friend class ContextPrivate;
0063     friend class TemplateImpl;
0064 
0065     Q_DISABLE_COPY(RenderContext)
0066     Q_DECLARE_PRIVATE(RenderContext)
0067     RenderContextPrivate *const d_ptr;
0068 #endif
0069 };
0070 }
0071 
0072 #endif