fixed: in Space serializer: we have to escape more characters
fixed: in SpaceParser::ReadTokenSingle the delimiter can be only if the character was not escaped git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@409 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -313,12 +313,8 @@ public:
|
||||
template<class Stream>
|
||||
void SerializeTableMulti(Stream & out, bool use_indents, int level) const;
|
||||
|
||||
template<class Stream>
|
||||
static void PrintValue(Stream & out, const std::wstring & str, bool use_quote = true);
|
||||
|
||||
// for other uses
|
||||
template<class Stream>
|
||||
static void PrintValue(Stream & out, const std::string & str, bool use_quote = true);
|
||||
template<class Stream, class StringType>
|
||||
static void PrintValue(Stream & out, const StringType & str, bool use_quote = true);
|
||||
|
||||
template<class Stream>
|
||||
static void PrintKey(Stream & out, const std::wstring & str);
|
||||
@@ -361,61 +357,28 @@ void Space::PrintLevel(Stream & out, bool use_indents, int level)
|
||||
|
||||
|
||||
|
||||
template<class Stream>
|
||||
void Space::PrintValue(Stream & out, const std::wstring & str, bool use_quote)
|
||||
|
||||
template<class Stream, class StringType>
|
||||
void Space::PrintValue(Stream & out, const StringType & str, bool use_quote)
|
||||
{
|
||||
if( use_quote )
|
||||
out << '\"';
|
||||
|
||||
for(size_t i=0 ; i<str.size() ; ++i)
|
||||
{
|
||||
if( str[i] == '\\' )
|
||||
out << L"\\\\";
|
||||
else
|
||||
if( str[i] == '"' )
|
||||
out << L"\\\"";
|
||||
else
|
||||
if( str[i] == '\r' )
|
||||
out << L"\\r";
|
||||
else
|
||||
if( str[i] == '\n' )
|
||||
out << L"\\n";
|
||||
else
|
||||
if( str[i] == 0 )
|
||||
out << L"\\0";
|
||||
else
|
||||
out << str[i];
|
||||
}
|
||||
|
||||
if( use_quote )
|
||||
out << '\"';
|
||||
}
|
||||
|
||||
|
||||
template<class Stream>
|
||||
void Space::PrintValue(Stream & out, const std::string & str, bool use_quote)
|
||||
{
|
||||
if( use_quote )
|
||||
out << '\"';
|
||||
|
||||
for(size_t i=0 ; i<str.size() ; ++i)
|
||||
{
|
||||
if( str[i] == '\\' )
|
||||
out << "\\\\";
|
||||
else
|
||||
if( str[i] == '"' )
|
||||
out << "\\\"";
|
||||
else
|
||||
if( str[i] == '\r' )
|
||||
out << "\\r";
|
||||
else
|
||||
if( str[i] == '\n' )
|
||||
out << "\\n";
|
||||
else
|
||||
if( str[i] == 0 )
|
||||
out << "\\0";
|
||||
else
|
||||
switch(str[i])
|
||||
{
|
||||
case 0: out << '\\'; out << '0'; break;
|
||||
case '\r': out << '\\'; out << 'r'; break;
|
||||
case '\n': out << '\\'; out << 'n'; break;
|
||||
case '\\': out << '\\'; out << '\\'; break;
|
||||
case '"': out << '\\'; out << '\"'; break;
|
||||
case '(': out << '\\'; out << '('; break;
|
||||
case ')': out << '\\'; out << ')'; break;
|
||||
case '=': out << '\\'; out << '='; break;
|
||||
default:
|
||||
out << str[i];
|
||||
}
|
||||
}
|
||||
|
||||
if( use_quote )
|
||||
|
Reference in New Issue
Block a user