added: Pattern::allow_include flag (default true)
if false there is no allowed [include ...] directive (this directive will be skipped) added: Pattern::ParseString(const std::string & str); Pattern::ParseString(const char * str); can create the pattern from a string git-svn-id: svn://ttmath.org/publicrep/ezc/trunk@94 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
f8f55eae77
commit
141e1f67b3
25
src/ezc.cpp
25
src/ezc.cpp
|
@ -118,6 +118,14 @@ void SplitUnixDirectory(const std::string & name, std::string & dir, std::string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
Pattern::Pattern()
|
||||||
|
{
|
||||||
|
allow_include = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Pattern::ParseFile(const std::string & file_name)
|
void Pattern::ParseFile(const std::string & file_name)
|
||||||
{
|
{
|
||||||
ParseFile( file_name.c_str() );
|
ParseFile( file_name.c_str() );
|
||||||
|
@ -141,6 +149,21 @@ std::string file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Pattern::ParseString(const std::string & str)
|
||||||
|
{
|
||||||
|
itext = str.c_str();
|
||||||
|
CreateTree(item_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pattern::ParseString(const char * str)
|
||||||
|
{
|
||||||
|
itext = str;
|
||||||
|
CreateTree(item_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Pattern::Directory(const char * d)
|
void Pattern::Directory(const char * d)
|
||||||
{
|
{
|
||||||
directory = d;
|
directory = d;
|
||||||
|
@ -524,7 +547,7 @@ return false;
|
||||||
|
|
||||||
void Pattern::CreateTreeReadInclude(Item & item)
|
void Pattern::CreateTreeReadInclude(Item & item)
|
||||||
{
|
{
|
||||||
if( item.directives.empty() || item.directives[0].empty() || item.directives[0][0]!='\"' )
|
if( !allow_include || item.directives.empty() || item.directives[0].empty() || item.directives[0][0]!='\"' )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string file_text = ReadFile( item.directives[0].c_str()+1 );
|
std::string file_text = ReadFile( item.directives[0].c_str()+1 );
|
||||||
|
|
|
@ -68,8 +68,12 @@ void SplitUnixDirectory(const std::string & name, std::string & dir, std::string
|
||||||
class Pattern
|
class Pattern
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Pattern();
|
||||||
|
|
||||||
void ParseFile(const std::string & file_name);
|
void ParseFile(const std::string & file_name);
|
||||||
void ParseFile(const char * file_name);
|
void ParseFile(const char * file_name);
|
||||||
|
void ParseString(const std::string & str);
|
||||||
|
void ParseString(const char * str);
|
||||||
void Directory(const char * d);
|
void Directory(const char * d);
|
||||||
void Directory(const std::string & d);
|
void Directory(const std::string & d);
|
||||||
|
|
||||||
|
@ -107,6 +111,8 @@ public:
|
||||||
|
|
||||||
Item item_root;
|
Item item_root;
|
||||||
|
|
||||||
|
bool allow_include;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char * itext;
|
const char * itext;
|
||||||
std::string directory;
|
std::string directory;
|
||||||
|
|
Loading…
Reference in New Issue