[cig-commits] commit: Fix '<' and '>' in json input
Mercurial
hg at geodynamics.org
Sat Nov 12 19:46:12 PST 2011
changeset: 403:04db9305c882
tag: tip
user: Walter Landry <wlandry at caltech.edu>
date: Sat Nov 12 19:46:00 2011 -0800
files: json_parser/print_xml.cxx
description:
Fix '<' and '>' in json input
diff -r 0260c7ce275c -r 04db9305c882 json_parser/print_xml.cxx
--- a/json_parser/print_xml.cxx Sat Nov 12 19:44:42 2011 -0800
+++ b/json_parser/print_xml.cxx Sat Nov 12 19:46:00 2011 -0800
@@ -4,6 +4,24 @@
#include "print_xml.h"
#include "fix_start_end.h"
+
+std::string fix_comparisons(const std::string &s)
+{
+ std::string result(s);
+ size_t i(result.find('<'));
+ while(i!=std::string::npos)
+ {
+ result.replace(i,1,"<");
+ i=result.find('<',i+1);
+ }
+ i=result.find('<');
+ while(i!=std::string::npos)
+ {
+ result.replace(i,1,">");
+ i=result.find('>',i+1);
+ }
+ return result;
+}
void print_xml(std::ostream &os, const std::string &name,
const json_spirit::Value &o)
@@ -13,7 +31,7 @@ void print_xml(std::ostream &os, const s
{
case json_spirit::str_type:
fix_start_end("param",name,start,end);
- os << start << o.get_str() << end;
+ os << start << fix_comparisons(o.get_str()) << end;
break;
case json_spirit::bool_type:
fix_start_end("param",name,start,end);
More information about the CIG-COMMITS
mailing list