From 31c35a93357db13cb8bc8d52f7de0303e67cf45c Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 4 May 2010 10:57:17 -0400 Subject: [PATCH] updated c_escape(); added TokenDefinition::getCString() --- TokenDefinition.cc | 7 ++++++- TokenDefinition.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/TokenDefinition.cc b/TokenDefinition.cc index 8835950..4ed808c 100644 --- a/TokenDefinition.cc +++ b/TokenDefinition.cc @@ -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); +} diff --git a/TokenDefinition.h b/TokenDefinition.h index c8a478a..7ee5a1c 100644 --- a/TokenDefinition.h +++ b/TokenDefinition.h @@ -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;