ezc/src/ezc.h

89 lines
2.1 KiB
C++

#ifndef headerfileezc
#define headerfileezc
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
class Ezc
{
public:
struct Info
{
std::string text;
bool result;
int iter;
};
typedef void (*UserFunction)(Info &);
struct UserInfo
{
UserFunction user_function;
int iter;
};
typedef std::map<std::string, UserInfo> UserInfoTable;
UserInfoTable user_info_table;
Ezc();
void Init();
bool ReadFile(const char * name);
void CreateTree();
std::string MakeText();
void Insert(const std::string & key, UserFunction ufunction);
private:
struct Item
{
enum ItemType
{
item_none, item_container, item_text, item_ifany, item_for, item_else,
item_end, item_err, item_normal
};
ItemType type;
std::string text;
std::vector<Item*> item_table;
std::vector<std::string> directives;
Item();
~Item();
Item * AddItem(const Item & porg);
void SkipWhiteCharacters(const char * & itext);
void ReadDirective(const char * & itext, std::string & directive);
void ClearTable();
ItemType LastItemType();
bool ReadChar(const char * & itext, char & result);
void CreateTreeReadItemDirectiveCheckEnding(const char * & itext);
void CreateTreeReadItemDirective(const char * & itext);
void CreateTreeReadItemText(const char * & itext);
bool CreateTreeReadItem(const char * & itext);
void CreateTreeReadAll(const char * & itext);
void CreateTreeReadIfany(const char * & itext);
void CreateTreeReadFor(const char * & itext);
bool CreateTreeReadDeleteLastEndItem();
void CreateTree(const char * & itext);
void MakeTextIfany(std::string & otext, UserInfoTable & user_info_table);
void MakeTextFor(std::string & otext, UserInfoTable & user_info_table);
void MakeTextContainer(std::string & otext, UserInfoTable & user_info_table);
void MakeTextMsgCantFind(std::string & otext, std::string & key);
void MakeTextNormal(std::string & otext, UserInfoTable & user_info_table);
void MakeText(std::string & otext,UserInfoTable & user_info_table);
};
Item item_root;
std::string input;
std::string output;
};
#endif