And another one
This commit is contained in:
parent
432328cc55
commit
91f25f0510
2 changed files with 2 additions and 41 deletions
|
@ -71,18 +71,6 @@ void XMLWriter::writeEmptyElement(const string & name,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XMLWriter::writeCharData(const string & data)
|
|
||||||
{
|
|
||||||
assert(!pendingElems.empty());
|
|
||||||
for (unsigned int i = 0; i < data.size(); ++i) {
|
|
||||||
char c = data[i];
|
|
||||||
if (c == '<') output << "<";
|
|
||||||
else if (c == '&') output << "&";
|
|
||||||
else output << c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void XMLWriter::writeAttrs(const XMLAttrs & attrs)
|
void XMLWriter::writeAttrs(const XMLAttrs & attrs)
|
||||||
{
|
{
|
||||||
for (XMLAttrs::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
|
for (XMLAttrs::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
|
||||||
|
@ -103,29 +91,4 @@ void XMLWriter::writeAttrs(const XMLAttrs & attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
int main(int argc, char * * argv)
|
|
||||||
{
|
|
||||||
XMLWriter doc(cout);
|
|
||||||
|
|
||||||
// OpenElement e(doc, "foo");
|
|
||||||
|
|
||||||
doc.openElement("foo");
|
|
||||||
|
|
||||||
doc.writeCharData("dit is een test &\n");
|
|
||||||
doc.writeCharData("<foo>\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
|
||||||
XMLAttrs attrs;
|
|
||||||
attrs["a"] = "b";
|
|
||||||
attrs["bla"] = "<foo>'&\">";
|
|
||||||
XMLOpenElement e(doc, "item", attrs);
|
|
||||||
doc.writeCharData("x");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ typedef map<string, string> XMLAttrs;
|
||||||
class XMLWriter
|
class XMLWriter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::ostream & output;
|
std::ostream & output;
|
||||||
|
|
||||||
bool indent;
|
bool indent;
|
||||||
|
@ -40,8 +40,6 @@ public:
|
||||||
|
|
||||||
void writeEmptyElement(const string & name,
|
void writeEmptyElement(const string & name,
|
||||||
const XMLAttrs & attrs = XMLAttrs());
|
const XMLAttrs & attrs = XMLAttrs());
|
||||||
|
|
||||||
void writeCharData(const string & data);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void writeAttrs(const XMLAttrs & attrs);
|
void writeAttrs(const XMLAttrs & attrs);
|
||||||
|
@ -67,5 +65,5 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue