Electroneum
render_context.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <deque>
4 #include <list>
5 #include <sstream>
6 #include <string>
7 #include <stack>
8 
9 #include "mstch/mstch.hpp"
10 #include "state/render_state.hpp"
11 #include "template_type.hpp"
12 
13 namespace mstch {
14 
16  public:
17  class push {
18  public:
20  ~push();
21  std::string render(const template_type& templt);
22  private:
24  };
25 
27  const mstch::node& node,
28  const std::map<std::string, template_type>& partials);
29  const mstch::node& get_node(const std::string& token);
30  std::string render(
31  const template_type& templt, const std::string& prefix = "");
32  std::string render_partial(
33  const std::string& partial_name, const std::string& prefix);
34  template<class T, class... Args>
35  void set_state(Args&& ... args) {
36  m_state.top() = std::unique_ptr<render_state>(
37  new T(std::forward<Args>(args)...));
38  }
39 
40  private:
41  static const mstch::node null_node;
42  const mstch::node& find_node(
43  const std::string& token,
44  std::list<node const*> current_nodes);
45  std::map<std::string, template_type> m_partials;
46  std::deque<mstch::node> m_nodes;
47  std::list<const mstch::node*> m_node_ptrs;
48  std::stack<std::unique_ptr<render_state>> m_state;
49 };
50 
51 }
Definition: render_context.hpp:17
const uint32_t T[512]
Definition: groestl_tables.h:34
render_context(const mstch::node &node, const std::map< std::string, template_type > &partials)
Definition: render_context.cpp:27
boost::make_recursive_variant< std::nullptr_t, std::string, int, double, bool, uint64_t, int64_t, uint32_t, internal::lambda_t< boost::recursive_variant_ >, std::shared_ptr< internal::object_t< boost::recursive_variant_ > >, internal::map< const std::string, boost::recursive_variant_ >, std::vector< boost::recursive_variant_ > >::type node
Definition: mstch.hpp:116
static const mstch::node null_node
Definition: render_context.hpp:41
std::list< const mstch::node * > m_node_ptrs
Definition: render_context.hpp:47
const mstch::node & find_node(const std::string &token, std::list< node const *> current_nodes)
Definition: render_context.cpp:35
const mstch::node & get_node(const std::string &token)
Definition: render_context.cpp:49
Definition: mstch.hpp:11
std::string render(const template_type &templt, const std::string &prefix="")
Definition: render_context.cpp:53
render_context & m_context
Definition: render_context.hpp:23
std::deque< mstch::node > m_nodes
Definition: render_context.hpp:46
void set_state(Args &&... args)
Definition: render_context.hpp:35
std::string render_partial(const std::string &partial_name, const std::string &prefix)
Definition: render_context.cpp:67
std::string render(const template_type &templt)
Definition: render_context.cpp:23
std::map< std::string, template_type > m_partials
Definition: render_context.hpp:45
Definition: template_type.hpp:11
push(render_context &context, const mstch::node &node={})
Definition: render_context.cpp:9
~push()
Definition: render_context.cpp:17
Definition: render_context.hpp:15
std::stack< std::unique_ptr< render_state > > m_state
Definition: render_context.hpp:48
Definition: token.hpp:9
json::wvalue context
Definition: mustache.h:12