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

0001 /*
0002   This file is part of the KTextTemplate library
0003 
0004   SPDX-FileCopyrightText: 2009, 2010 Stephen Kelly <steveire@gmail.com>
0005 
0006   SPDX-License-Identifier: LGPL-2.1-or-later
0007 
0008 */
0009 
0010 #ifndef NODE_BUILTINS_H
0011 #define NODE_BUILTINS_H
0012 
0013 #include "node.h"
0014 
0015 namespace KTextTemplate
0016 {
0017 
0018 /**
0019   @internal
0020 
0021   A Node for plain text. Plain text is everything between variables, comments
0022   and template tags.
0023 */
0024 class KTEXTTEMPLATE_EXPORT TextNode : public Node
0025 {
0026     Q_OBJECT
0027 public:
0028     explicit TextNode(const QString &content, QObject *parent = {});
0029 
0030     void render(OutputStream *stream, Context *c) const override
0031     { // krazy:exclude:inline
0032         Q_UNUSED(c);
0033         (*stream) << m_content;
0034     }
0035 
0036 private:
0037     const QString m_content;
0038 };
0039 
0040 /**
0041   @internal
0042 
0043   A node for a variable or filter expression substitution.
0044 */
0045 class KTEXTTEMPLATE_EXPORT VariableNode : public Node
0046 {
0047     Q_OBJECT
0048 public:
0049     explicit VariableNode(const FilterExpression &fe, QObject *parent = {});
0050 
0051     void render(OutputStream *stream, Context *c) const override;
0052 
0053 private:
0054     FilterExpression m_filterExpression;
0055 };
0056 }
0057 
0058 #endif