46 if(attribute.first.empty())
48 out <<
' ' << attribute.first
68 for(const auto &element : elements) 69 element.output(out, indent+2); 71 do_indent(out, indent); 74 out << '<
' << '/
' << name << '>
' << "\n"; 78 void xmlt::escape(const std::string &s, std::ostream &out) 80 for(const auto ch : s) 104 // � isn't allowed, but what shall we
do?
105 if((ch>=0 && ch<
' ') || ch==127)
117 for(
const auto ch : s)
139 if((ch>=0 && ch<
' ') || ch==127)
149 out << std::string(indent,
' ');
152 xmlt::elementst::const_iterator
xmlt::find(
const std::string &name)
const 154 for(elementst::const_iterator it=
elements.begin();
163 xmlt::elementst::iterator
xmlt::find(
const std::string &name)
165 for(elementst::iterator it=
elements.begin();
175 const std::string &attribute,
182 const std::string &attribute,
189 const std::string &attribute,
190 unsigned long long value)
196 const std::string &attribute,
197 const std::string &value)
199 if((value[0]==
'\"' && value[value.size()-1]==
'\"') ||
200 (value[0]==
'\'' && value[value.size()-1]==
'\''))
202 attributes[attribute]=value.substr(1, value.size()-2);
215 std::string result(
"");
217 result.reserve(str.size());
219 for(std::string::const_iterator it=str.begin();
228 while(it!=str.end() && *it!=
';')
237 else if(tmp[0]==
'#' && tmp[1]!=
'x')
243 throw "XML escape code not implemented";
elementst::const_iterator find(const std::string &name) const
xmlt xml(const source_locationt &location)
void set_attribute(const std::string &attribute, unsigned value)
static std::string unescape(const std::string &s)
takes a string and unescapes any xml style escaped symbols
std::string to_string(const string_constraintt &expr)
Used for debug printing.
static void do_indent(std::ostream &out, unsigned indent)
static void escape_attribute(const std::string &s, std::ostream &out)
escaping for XML attributes, assuming that double quotes " are used consistently, not single quotes ...
int unsafe_string2int(const std::string &str, int base)
void output(std::ostream &out, unsigned indent=0) const