initial import
git-svn-id: svn://ttmath.org/publicrep/cgi/ezc/trunk@4 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
commit
700dcd0571
3 files changed
+519
No files matched your search
@@ -0,0 +1,81 @@
|
||||
#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
|
||||
Reference in new issue
Block a user