1 |
#ifndef headerfileezc |
2 |
#define headerfileezc |
3 |
|
4 |
#include <string> |
5 |
#include <sstream> |
6 |
#include <fstream> |
7 |
#include <vector> |
8 |
#include <map> |
9 |
|
10 |
|
11 |
class Ezc |
12 |
{ |
13 |
public: |
14 |
struct Info |
15 |
{ |
16 |
std::string text; |
17 |
bool result; |
18 |
int iter; |
19 |
}; |
20 |
|
21 |
typedef void (*UserFunction)(Info &); |
22 |
|
23 |
struct UserInfo |
24 |
{ |
25 |
UserFunction user_function; |
26 |
int iter; |
27 |
}; |
28 |
|
29 |
typedef std::map<std::string, UserInfo> UserInfoTable; |
30 |
|
31 |
UserInfoTable user_info_table; |
32 |
|
33 |
Ezc(); |
34 |
void Init(); |
35 |
bool ReadFile(const char * name); |
36 |
void CreateTree(); |
37 |
std::string MakeText(); |
38 |
void Insert(const std::string & key, UserFunction ufunction); |
39 |
|
40 |
private: |
41 |
struct Item |
42 |
{ |
43 |
enum ItemType |
44 |
{ |
45 |
item_none, item_container, item_text, item_ifany, item_for, item_else, |
46 |
item_end, item_err, item_normal |
47 |
}; |
48 |
|
49 |
ItemType type; |
50 |
std::string text; |
51 |
std::vector<Item*> item_table; |
52 |
|
53 |
std::vector<std::string> directives; |
54 |
|
55 |
Item(); |
56 |
~Item(); |
57 |
Item * AddItem(const Item & porg); |
58 |
void SkipWhiteCharacters(const char * & itext); |
59 |
void ReadDirective(const char * & itext, std::string & directive); |
60 |
void ClearTable(); |
61 |
ItemType LastItemType(); |
62 |
bool ReadChar(const char * & itext, char & result); |
63 |
void CreateTreeReadItemDirectiveCheckEnding(const char * & itext); |
64 |
void CreateTreeReadItemDirective(const char * & itext); |
65 |
void CreateTreeReadItemText(const char * & itext); |
66 |
bool CreateTreeReadItem(const char * & itext); |
67 |
void CreateTreeReadAll(const char * & itext); |
68 |
void CreateTreeReadIfany(const char * & itext); |
69 |
void CreateTreeReadFor(const char * & itext); |
70 |
bool CreateTreeReadDeleteLastEndItem(); |
71 |
void CreateTree(const char * & itext); |
72 |
|
73 |
void MakeTextIfany(std::string & otext, UserInfoTable & user_info_table); |
74 |
void MakeTextFor(std::string & otext, UserInfoTable & user_info_table); |
75 |
void MakeTextContainer(std::string & otext, UserInfoTable & user_info_table); |
76 |
void MakeTextMsgCantFind(std::string & otext, std::string & key); |
77 |
void MakeTextNormal(std::string & otext, UserInfoTable & user_info_table); |
78 |
|
79 |
void MakeText(std::string & otext,UserInfoTable & user_info_table); |
80 |
}; |
81 |
|
82 |
Item item_root; |
83 |
std::string input; |
84 |
std::string output; |
85 |
}; |
86 |
|
87 |
|
88 |
#endif |