Browse Source

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
master
Tomasz Sowa 13 years ago
parent
commit
141e1f67b3
  1. 25
      src/ezc.cpp
  2. 6
      src/ezc.h

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)
{
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)
{
directory = d;
@ -524,7 +547,7 @@ return false;
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;
std::string file_text = ReadFile( item.directives[0].c_str()+1 );

6
src/ezc.h

@ -68,8 +68,12 @@ void SplitUnixDirectory(const std::string & name, std::string & dir, std::string
class Pattern
{
public:
Pattern();
void ParseFile(const std::string & 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 std::string & d);
@ -107,6 +111,8 @@ public:
Item item_root;
bool allow_include;
private:
const char * itext;
std::string directory;

Loading…
Cancel
Save