Inja 3.3.0
A Template Engine for Modern C++
Loading...
Searching...
No Matches
statistics.hpp
1#ifndef INCLUDE_INJA_STATISTICS_HPP_
2#define INCLUDE_INJA_STATISTICS_HPP_
3
4#include "node.hpp"
5
6
7namespace inja {
8
13 void visit(const BlockNode& node) {
14 for (auto& n : node.nodes) {
15 n->accept(*this);
16 }
17 }
18
19 void visit(const TextNode&) { }
20 void visit(const ExpressionNode&) { }
21 void visit(const LiteralNode&) { }
22
23 void visit(const JsonNode&) {
24 variable_counter += 1;
25 }
26
27 void visit(const FunctionNode& node) {
28 for (auto& n : node.arguments) {
29 n->accept(*this);
30 }
31 }
32
33 void visit(const ExpressionListNode& node) {
34 node.root->accept(*this);
35 }
36
37 void visit(const StatementNode&) { }
38 void visit(const ForStatementNode&) { }
39
40 void visit(const ForArrayStatementNode& node) {
41 node.condition.accept(*this);
42 node.body.accept(*this);
43 }
44
45 void visit(const ForObjectStatementNode& node) {
46 node.condition.accept(*this);
47 node.body.accept(*this);
48 }
49
50 void visit(const IfStatementNode& node) {
51 node.condition.accept(*this);
52 node.true_statement.accept(*this);
53 node.false_statement.accept(*this);
54 }
55
56 void visit(const IncludeStatementNode&) { }
57
58 void visit(const ExtendsStatementNode&) { }
59
60 void visit(const BlockStatementNode& node) {
61 node.block.accept(*this);
62 }
63
64 void visit(const SetStatementNode&) { }
65
66public:
67 unsigned int variable_counter;
68
69 explicit StatisticsVisitor() : variable_counter(0) { }
70};
71
72} // namespace inja
73
74#endif // INCLUDE_INJA_STATISTICS_HPP_
Definition: node.hpp:70
Definition: node.hpp:347
Definition: node.hpp:254
Definition: node.hpp:92
Definition: node.hpp:336
Definition: node.hpp:284
Definition: node.hpp:295
Definition: node.hpp:273
Definition: node.hpp:135
Definition: node.hpp:307
Definition: node.hpp:325
Definition: node.hpp:112
Definition: node.hpp:101
Definition: node.hpp:34
Definition: node.hpp:360
Definition: node.hpp:266
A class for counting statistics on a Template.
Definition: statistics.hpp:12
Definition: node.hpp:81