82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
#ifndef headerfileezc
|
|
#define headerfileezc
|
|
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <fstream>
|
|
#include <vector>
|
|
#include <map>
|
|
|
|
struct EzcInfo
|
|
{
|
|
std::string text;
|
|
bool result;
|
|
|
|
EzcInfo()
|
|
{
|
|
result = false;
|
|
}
|
|
};
|
|
|
|
class Ezc
|
|
{
|
|
public:
|
|
typedef void (*UserFunction)(EzcInfo &);
|
|
typedef std::map<std::string, UserFunction> UserFunctions;
|
|
|
|
UserFunctions user_functions;
|
|
|
|
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 CreateTree(const char * & itext);
|
|
|
|
void MakeTextIfany(std::string & otext, UserFunctions & user_functions);
|
|
void MakeTextContainer(std::string & otext, UserFunctions & user_functions);
|
|
void MakeTextMsgCantFind(std::string & otext, std::string & key);
|
|
void MakeTextNormal(std::string & otext, UserFunctions & user_functions);
|
|
|
|
void MakeText(std::string & otext,UserFunctions & user_functions);
|
|
};
|
|
|
|
Item item_root;
|
|
std::string input;
|
|
std::string output;
|
|
};
|
|
|
|
|
|
#endif
|