mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-06-08 15:16:52 +02:00
start work on webconsole with templates
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
47460d86b2
commit
a843be75f3
60 changed files with 24925 additions and 38 deletions
73
libi2pd_webconsole/inja/statistics.hpp
Normal file
73
libi2pd_webconsole/inja/statistics.hpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#ifndef INCLUDE_INJA_STATISTICS_HPP_
|
||||
#define INCLUDE_INJA_STATISTICS_HPP_
|
||||
|
||||
#include "node.hpp"
|
||||
|
||||
namespace inja {
|
||||
|
||||
/*!
|
||||
* \brief A class for counting statistics on a Template.
|
||||
*/
|
||||
class StatisticsVisitor : public NodeVisitor {
|
||||
void visit(const BlockNode& node) {
|
||||
for (auto& n : node.nodes) {
|
||||
n->accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void visit(const TextNode&) {}
|
||||
void visit(const ExpressionNode&) {}
|
||||
void visit(const LiteralNode&) {}
|
||||
|
||||
void visit(const DataNode&) {
|
||||
variable_counter += 1;
|
||||
}
|
||||
|
||||
void visit(const FunctionNode& node) {
|
||||
for (auto& n : node.arguments) {
|
||||
n->accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void visit(const ExpressionListNode& node) {
|
||||
node.root->accept(*this);
|
||||
}
|
||||
|
||||
void visit(const StatementNode&) {}
|
||||
void visit(const ForStatementNode&) {}
|
||||
|
||||
void visit(const ForArrayStatementNode& node) {
|
||||
node.condition.accept(*this);
|
||||
node.body.accept(*this);
|
||||
}
|
||||
|
||||
void visit(const ForObjectStatementNode& node) {
|
||||
node.condition.accept(*this);
|
||||
node.body.accept(*this);
|
||||
}
|
||||
|
||||
void visit(const IfStatementNode& node) {
|
||||
node.condition.accept(*this);
|
||||
node.true_statement.accept(*this);
|
||||
node.false_statement.accept(*this);
|
||||
}
|
||||
|
||||
void visit(const IncludeStatementNode&) {}
|
||||
|
||||
void visit(const ExtendsStatementNode&) {}
|
||||
|
||||
void visit(const BlockStatementNode& node) {
|
||||
node.block.accept(*this);
|
||||
}
|
||||
|
||||
void visit(const SetStatementNode&) {}
|
||||
|
||||
public:
|
||||
unsigned int variable_counter;
|
||||
|
||||
explicit StatisticsVisitor(): variable_counter(0) {}
|
||||
};
|
||||
|
||||
} // namespace inja
|
||||
|
||||
#endif // INCLUDE_INJA_STATISTICS_HPP_
|
Loading…
Add table
Add a link
Reference in a new issue