added: method ConfParser::UseEscapeChar(bool escape)

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@642 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-08-16 14:15:37 +00:00
parent ca4e53bb0f
commit eec0ddf466
2 changed files with 22 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ ConfParser::ConfParser()
list_delimiter = ','; list_delimiter = ',';
split_single = false; split_single = false;
skip_empty = false; skip_empty = false;
use_escape_char = true;
default_str = ""; default_str = "";
default_int = 0; default_int = 0;
@@ -45,6 +46,12 @@ void ConfParser::SkipEmpty(bool skip)
} }
void ConfParser::UseEscapeChar(bool escape)
{
use_escape_char = escape;
}
ConfParser::Status ConfParser::Parse(const char * file_name) ConfParser::Status ConfParser::Parse(const char * file_name)
{ {
line = 1; line = 1;
@@ -253,7 +260,7 @@ bool ConfParser::ReadValueQuoted()
while( lastc != '"' && lastc != -1 ) while( lastc != '"' && lastc != -1 )
{ {
if( lastc == '\\' ) if( use_escape_char && lastc == '\\' )
ReadChar(); ReadChar();
value_item += lastc; value_item += lastc;

View File

@@ -122,6 +122,7 @@ config syntax:
"\a" gives "a" "\a" gives "a"
"\\" gives "\" "\\" gives "\"
"\Z" gives "Z" and so on "\Z" gives "Z" and so on
you can call UseEscapeChar(false) to turn this off
*/ */
@@ -202,6 +203,15 @@ public:
void SkipEmpty(bool skip); void SkipEmpty(bool skip);
/*
'\' character is used to escape other characters in a quoted string
so "some \t t\"ext" will produce "some t t"ext"
(this is only use in quoted string)
default: true
*/
void UseEscapeChar(bool escape);
/* /*
those methods are used to extract information from table or table_single those methods are used to extract information from table or table_single
as a parameter they take the name of an option as a parameter they take the name of an option
@@ -325,6 +335,10 @@ private:
bool skip_empty; bool skip_empty;
/*
if true you can use an escape character '\' in quoted values
*/
bool use_escape_char;
std::string default_str; std::string default_str;
int default_int; int default_int;