updated c_escape(); added TokenDefinition::getCString()

This commit is contained in:
Josh Holtrop 2010-05-04 10:57:17 -04:00
parent 7756bd696b
commit 31c35a9335
2 changed files with 7 additions and 1 deletions

View File

@ -13,7 +13,7 @@ static string c_escape(const string & orig)
string result;
for (string::const_iterator it = orig.begin(); it != orig.end(); it++)
{
if (*it == '\\')
if (*it == '\\' || *it == '"')
result += '\\';
result += *it;
}
@ -37,3 +37,8 @@ bool TokenDefinition::create(const string & name,
pcre_free(re);
return true;
}
string TokenDefinition::getCString() const
{
return c_escape(m_definition);
}

View File

@ -9,6 +9,7 @@ class TokenDefinition
public:
bool create(const std::string & name,
const std::string & definition, const std::string & flags);
std::string getCString() const;
protected:
std::string m_name;