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:
+18
-76
@@ -36,12 +36,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef headerfile_ezc_pattern
|
||||
#define headerfile_ezc_pattern
|
||||
#ifndef headerfile_ezc_patternparser
|
||||
#define headerfile_ezc_patternparser
|
||||
|
||||
#include <string>
|
||||
#include "item.h"
|
||||
#include "functions.h"
|
||||
#include "pattern.h"
|
||||
#include "stringconv.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
@@ -54,17 +52,11 @@ namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
class Pattern
|
||||
class PatternParser
|
||||
{
|
||||
public:
|
||||
|
||||
Pattern();
|
||||
|
||||
/*!
|
||||
clearing only the tree
|
||||
*/
|
||||
void Clear();
|
||||
|
||||
PatternParser();
|
||||
|
||||
// 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
|
||||
@@ -77,17 +69,15 @@ public:
|
||||
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 char * file_name, Pattern & pattern);
|
||||
void ParseFile(const std::string & file_name, Pattern & pattern);
|
||||
void ParseFile(const wchar_t * file_name, Pattern & pattern);
|
||||
void ParseFile(const std::wstring & file_name, Pattern & pattern);
|
||||
|
||||
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 ParseString(const char * str, Pattern & pattern);
|
||||
void ParseString(const std::string & str, Pattern & pattern);
|
||||
void ParseString(const wchar_t * str, Pattern & pattern);
|
||||
void ParseString(const std::wstring & str, Pattern & pattern);
|
||||
|
||||
void AllowInclude(bool allow);
|
||||
void DeleteWhiteTextItems(bool del);
|
||||
@@ -97,26 +87,13 @@ public:
|
||||
// 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;
|
||||
|
||||
template<class StreamType>
|
||||
void CacheFunctions(Functions<StreamType> & fun)
|
||||
{
|
||||
CacheFunctions(item_root, fun);
|
||||
}
|
||||
|
||||
void ClearCache();
|
||||
|
||||
private:
|
||||
|
||||
// the output object
|
||||
Pattern * pat;
|
||||
|
||||
// the main pointer to the parsed text
|
||||
const wchar_t * itext;
|
||||
|
||||
@@ -143,10 +120,6 @@ private:
|
||||
int include_level, include_level_max;
|
||||
|
||||
|
||||
|
||||
std::wstring commentary_start, commentary_stop;
|
||||
|
||||
|
||||
// temporary content for ParseString(const char*) method
|
||||
std::wstring string_content;
|
||||
|
||||
@@ -173,6 +146,7 @@ private:
|
||||
void ReadFileContent(std::ifstream & file, std::wstring & result);
|
||||
|
||||
int ReadCharInText();
|
||||
bool IsWhite(wchar_t c);
|
||||
void SkipWhite();
|
||||
void CheckWhiteAndDelete(std::wstring & s);
|
||||
|
||||
@@ -214,39 +188,7 @@ private:
|
||||
void CreateTreeReadIncludeSkipAllowFlag(Item & item);
|
||||
|
||||
|
||||
template<class StreamType>
|
||||
void CacheFunctions(Item & item, Functions<StreamType> & fun)
|
||||
{
|
||||
typename Functions<StreamType>::Function * ezc_fun;
|
||||
|
||||
// one exception (if_index is putting its argument on the functions stack)
|
||||
if( item.type != Item::item_ifindex )
|
||||
{
|
||||
for(size_t f=0; f < item.functions.size() ; ++f)
|
||||
{
|
||||
if( fun.Find(item.functions[f].name, &ezc_fun) )
|
||||
{
|
||||
item.functions[f].fun_cache = ezc_fun;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.functions[f].fun_cache = 0;
|
||||
|
||||
#ifdef EZC_USE_WINIX_LOGGER
|
||||
Winix::log << Winix::log1 << "Ezc: unknown function: " << item.functions[f].name << Winix::logend;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t i=0; i < item.item_tab.size() ; ++i)
|
||||
CacheFunctions(*item.item_tab[i], fun);
|
||||
}
|
||||
|
||||
|
||||
void ClearCache(Item & item);
|
||||
|
||||
}; // class Pattern
|
||||
}; // class PatternParser
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user