ICG 2
Electric Boogaloo
ICGTemplateEngine.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <algorithm>
5 #include <vector>
6 #include <unordered_set>
7 #include <map>
8 #include <sstream>
9 
10 /******************************************/
11 /* Data Structures */
12 /******************************************/
13 
14 namespace ICGTemplateEngine {
15 
16 
21  typedef std::map<std::string, std::string> Dictionary;
22 
23  class recursable;
24 
29  typedef std::map<std::string, std::vector<const recursable *>> ListTokenItems;
30 
35  class recursable {
36  public:
37 
43  virtual Dictionary toDictionary() const = 0;
44 
50  virtual ListTokenItems nextLevel() const = 0;
51 
57  virtual std::string toString() const = 0;
58  };
59 
68  std::string process(const std::string& template_to_fill, const Dictionary& token_dictionary, const ListTokenItems& recursable_map);
69 
78  std::string process(const Dictionary& token_dictionary, const ListTokenItems& recursable_list);
79 }
80 
81 
An interface for an object that has some attributes that should be used in a list_ token,...
Definition: ICGTemplateEngine.hpp:35
virtual ListTokenItems nextLevel() const =0
Get the value of any recursable objects nested in this one. May return empty if this is a "leaf".
virtual Dictionary toDictionary() const =0
Get a map of token name -> token value for this object.
virtual std::string toString() const =0
Get a string representation.
Definition: ICGTemplateEngine.hpp:14
std::map< std::string, std::vector< const recursable * > > ListTokenItems
Lists that we can recurse into.
Definition: ICGTemplateEngine.hpp:23
std::map< std::string, std::string > Dictionary
Map of token name to string it should be replaced with.
Definition: ICGTemplateEngine.hpp:21
std::string process(const std::string &template_to_fill, const Dictionary &token_dictionary, const ListTokenItems &recursable_map)
Definition: ICGTemplateEngine.cpp:83