ezc/src/ezc.h

94 lines
2.5 KiB
C++

#ifndef headerfileezc
#define headerfileezc
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include <cstdlib>
#include <cstring>
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();
void CreateTree(const char * file);
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, item_ifindex, item_include, item_is
};
ItemType type;
std::string text;
std::vector<Item*> item_table;
std::vector<std::string> directives;
Item();
~Item();
Item * AddItem(const Item & porg);
void ReadFile(const char * name, std::string & result);
void SkipWhiteCharacters(const char * & itext);
void ReadDirective(const char * & itext, std::string & directive);
void ReadString(const char * & itext, std::string & directive);
void ReadDirectiveOrString(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 CreateTreeReadIf(const char * & itext);
void CreateTreeReadFor(const char * & itext);
bool CreateTreeReadDeleteLastEndItem();
void CreateTreeReadInclude();
void CreateTree(const char * & itext);
void MakeTextIfany(std::string & otext, UserInfoTable & user_info_table);
void MakeTextIfindex(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 MakeTextIs(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