Inja  3.4.0
A Template Engine for Modern C++
template.hpp
1 #ifndef INCLUDE_INJA_TEMPLATE_HPP_
2 #define INCLUDE_INJA_TEMPLATE_HPP_
3 
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 #include "node.hpp"
10 #include "statistics.hpp"
11 
12 namespace inja {
13 
17 struct Template {
18  BlockNode root;
19  std::string content;
20  std::map<std::string, std::shared_ptr<BlockStatementNode>> block_storage;
21 
22  explicit Template() {}
23  explicit Template(const std::string& content): content(content) {}
24 
27  auto statistic_visitor = StatisticsVisitor();
28  root.accept(statistic_visitor);
29  return statistic_visitor.variable_counter;
30  }
31 };
32 
33 using TemplateStorage = std::map<std::string, Template>;
34 
35 } // namespace inja
36 
37 #endif // INCLUDE_INJA_TEMPLATE_HPP_
Definition: node.hpp:66
A class for counting statistics on a Template.
Definition: statistics.hpp:11
The main inja Template.
Definition: template.hpp:17
int count_variables()
Return number of variables (total number, not distinct ones) in the template.
Definition: template.hpp:26