changed: Pattern class has been split into two classes: Pattern and PatternParser
in Pattern we have only the tree in PatternParser there is the whole logic used to parse a file git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@969 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
156
src/pattern.h
156
src/pattern.h
@@ -42,12 +42,6 @@
|
||||
#include <string>
|
||||
#include "item.h"
|
||||
#include "functions.h"
|
||||
#include "stringconv.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
#ifdef EZC_USE_WINIX_LOGGER
|
||||
#include "core/log.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Ezc
|
||||
@@ -60,52 +54,8 @@ public:
|
||||
|
||||
Pattern();
|
||||
|
||||
/*!
|
||||
clearing only the tree
|
||||
*/
|
||||
void Clear();
|
||||
|
||||
|
||||
// first we're trying to read a file from directory dir
|
||||
// if there is no such a file there then we try read from dir2
|
||||
// (the second dir2 can be empty - it will not be used)
|
||||
void Directory(const char * dir, const char * dir2 = 0);
|
||||
void Directory(const std::string & dir);
|
||||
void Directory(const std::string & dir, const std::string & dir2);
|
||||
|
||||
void Directory(const wchar_t * dir, const wchar_t * dir2 = 0);
|
||||
void Directory(const std::wstring & dir);
|
||||
void Directory(const std::wstring & dir, const std::wstring & dir2);
|
||||
|
||||
void ParseFile(const char * file_name);
|
||||
void ParseFile(const std::string & file_name);
|
||||
|
||||
void ParseFile(const wchar_t * file_name);
|
||||
void ParseFile(const std::wstring & file_name);
|
||||
|
||||
|
||||
void ParseString(const char * str);
|
||||
void ParseString(const std::string & str);
|
||||
void ParseString(const wchar_t * str);
|
||||
void ParseString(const std::wstring & str);
|
||||
|
||||
void AllowInclude(bool allow);
|
||||
void DeleteWhiteTextItems(bool del);
|
||||
void SetIncludeMax(int include_max);
|
||||
|
||||
// files and strings (only char* and std::string) are treated
|
||||
// as UTF-8
|
||||
void UTF8(bool utf8);
|
||||
|
||||
void SetCommentary(const char * com_start, const char * com_stop);
|
||||
void SetCommentary(const std::string & com_start, const std::string & com_stop);
|
||||
void SetCommentary(const wchar_t * com_start, const wchar_t * com_stop);
|
||||
void SetCommentary(const std::wstring & com_start, const std::wstring & com_stop);
|
||||
|
||||
void CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg = 0);
|
||||
static bool IsWhite(wchar_t c);
|
||||
|
||||
Item item_root;
|
||||
void ClearCache();
|
||||
|
||||
template<class StreamType>
|
||||
void CacheFunctions(Functions<StreamType> & fun)
|
||||
@@ -113,107 +63,23 @@ public:
|
||||
CacheFunctions(item_root, fun);
|
||||
}
|
||||
|
||||
void ClearCache();
|
||||
void SetCommentary(const char * com_start, const char * com_stop);
|
||||
void SetCommentary(const std::string & com_start, const std::string & com_stop);
|
||||
void SetCommentary(const wchar_t * com_start, const wchar_t * com_stop);
|
||||
void SetCommentary(const std::wstring & com_start, const std::wstring & com_stop);
|
||||
|
||||
void CreateMsg(std::wstring & out, const wchar_t * type, const wchar_t * arg = 0);
|
||||
|
||||
|
||||
Item item_root;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// the main pointer to the parsed text
|
||||
const wchar_t * itext;
|
||||
|
||||
|
||||
// allowing include tag
|
||||
// default: true
|
||||
bool allow_include;
|
||||
|
||||
// if true all text-items which have only white characters (with new lines as well)
|
||||
// will be deleted - useful in *.txt templates
|
||||
// this not actually delete the whole item but only the string
|
||||
// the item will be present with an empty string
|
||||
// default: false
|
||||
bool delete_white_text_items;
|
||||
|
||||
// first we're trying to read a file from 'directory'
|
||||
// if there is no such a file there then we try read from 'directory2'
|
||||
// we read from these directories only if they are not empty
|
||||
std::wstring directory, directory2;
|
||||
|
||||
|
||||
bool input_as_utf8;
|
||||
|
||||
int include_level, include_level_max;
|
||||
|
||||
|
||||
|
||||
std::wstring commentary_start, commentary_stop;
|
||||
|
||||
|
||||
// temporary content for ParseString(const char*) method
|
||||
std::wstring string_content;
|
||||
|
||||
// temporary object for a file name
|
||||
std::wstring file_name;
|
||||
|
||||
// temporary object for a file name
|
||||
std::string afile_name;
|
||||
|
||||
// temporary object for a EZC function's parameter
|
||||
std::wstring temp_param;
|
||||
|
||||
// temporary object for a EZC function
|
||||
Item::Function temp_function;
|
||||
|
||||
|
||||
|
||||
void ReadFile(const std::wstring & name, std::wstring & result);
|
||||
void ReadFile(const wchar_t * name, std::wstring & result);
|
||||
bool HasFileAtBeginning(const wchar_t * path, const wchar_t * file);
|
||||
bool IsFileCorrect(const wchar_t * name);
|
||||
bool ReadFileFromDir(const std::wstring & dir, const wchar_t * name, std::wstring & result);
|
||||
void ReadFile(std::ifstream & file, std::wstring & result);
|
||||
void ReadFileContent(std::ifstream & file, std::wstring & result);
|
||||
|
||||
int ReadCharInText();
|
||||
void SkipWhite();
|
||||
void CheckWhiteAndDelete(std::wstring & s);
|
||||
|
||||
bool IsNameChar(wchar_t c);
|
||||
bool IsDigit(wchar_t c);
|
||||
bool IsPositiveNumber(const std::wstring & str);
|
||||
|
||||
bool ReadName(std::wstring & name);
|
||||
bool ReadString(std::wstring & str);
|
||||
bool ReadParams(Item::Function & function);
|
||||
bool ReadFunction(Item::Function & function);
|
||||
bool ReadFunctions(Item & item);
|
||||
|
||||
void ReadDirectiveIf(Item & item);
|
||||
void ReadDirectiveIfno(Item & item);
|
||||
void ReadDirectiveIfany(Item & item);
|
||||
void ReadDirectiveIfone(Item & item);
|
||||
void ReadDirectiveIfanyno(Item & item);
|
||||
void ReadDirectiveIfoneno(Item & item);
|
||||
void ReadDirectiveIs(Item & item);
|
||||
void ReadDirectiveIsno(Item & item);
|
||||
void ReadDirectiveIfindex(Item & item);
|
||||
void ReadDirectiveFor(Item & item);
|
||||
void ReadDirectiveComment(Item & item);
|
||||
void ReadDirectiveInclude(Item & item);
|
||||
void ReadDirectiveDef(Item & item);
|
||||
void ReadDirectiveFilter(Item & item);
|
||||
void ReadDirectiveEzc(Item & item);
|
||||
void ReadDirectiveNormal(const std::wstring & name, Item & item);
|
||||
|
||||
void CreateTreeReadItemDirectiveCheckEnding(Item & item);
|
||||
void CreateTreeReadItemDirective(Item & item);
|
||||
void CreateTreeReadItemText(Item & item);
|
||||
bool CreateTreeReadItem(Item & item);
|
||||
void CreateTreeReadIf(Item & item);
|
||||
void CreateTreeReadFor(Item & item);
|
||||
void CreateTree(Item & item);
|
||||
void CreateTreeReadInclude(Item & item);
|
||||
void CreateTreeReadIncludeSkipAllowFlag(Item & item);
|
||||
|
||||
|
||||
template<class StreamType>
|
||||
void CacheFunctions(Item & item, Functions<StreamType> & fun)
|
||||
{
|
||||
|
Reference in New Issue
Block a user