-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.hpp
108 lines (77 loc) · 1.93 KB
/
template.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
Copyright © 2015 Felipe Tavares <[email protected]>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the LICENSE file for more details.
*/
#ifndef BAKE_TEMPLATE_H
#define BAKE_TEMPLATE_H
#include <vector>
#include <string>
#include "bakefile.hpp"
#include "post.hpp"
using namespace std;
namespace bake {
class Tree {
class Node {
public:
string name;
string text;
Node *parent;
vector<Node *> children;
Node(Node *);
~Node();
void add(Node *);
Node* child();
unsigned int count();
string get_post(Post *, string = "");
string get_begin();
string get_end();
Node* get_post_template();
private:
bool is_extension(string &, string);
string to_html(string&);
};
Node *root;
Node *ptr;
public:
Tree();
~Tree();
Tree(Node *);
void create();
void up();
void down();
void push_name(char);
void push_text(char);
unsigned int count();
string get_post(Post *);
string get_begin();
string get_end();
Tree* get_post_template();
};
class Template {
static const unsigned int back_buffer_size = 32;
enum CommentType {
NONE, STYLE, SCRIPT
};
string path;
unsigned int state;
bool zero_cost_state_change;
CommentType comment;
vector<unsigned int> entry;
string prev;
Tree *tree;
public:
Template(string);
~Template();
Tree* read();
private:
void process(char);
void move_state(unsigned int);
void next_state(unsigned int);
// Avoid copying
Template(const Template&);
Template& operator=(const Template&);
};
}
#endif /* BAKE_TEMPLATE_H */