15 XML_Writer(std::ostream& output) :
16 m_s(output), _indent(
" "), _level(0) {}
17 virtual ~XML_Writer() {}
23 std::ostream& output() {
27 inline std::string XML_filter(std::string name) {
28 int ns =
static_cast<int>(name.size());
30 for (
int m = 0; m < ns; m++)
52 inline void XML_comment(std::ostream& s,
const std::string& comment) {
53 for (
int n = 0; n < _level; n++) {
56 s <<
"<!--" << comment <<
"-->" << std::endl;
59 inline void XML_open(std::ostream& s,
const std::string& tag,
const std::string p =
"") {
60 for (
int n = 0; n < _level; n++) {
64 s <<
"<" << XML_filter(tag) << p <<
">" << std::endl;
67 inline void XML_close(std::ostream& s,
const std::string& tag) {
69 for (
int n = 0; n < _level; n++) {
72 s <<
"</" << XML_filter(tag) <<
">" << std::endl;
76 void XML_item(std::ostream& s,
const std::string& tag, T value) {
77 for (
int n = 0; n < _level; n++) {
80 s <<
"<" << XML_filter(tag) <<
">"
81 << value <<
"</" << tag <<
">" << std::endl;
85 void XML_writeVector(std::ostream& s,
const std::string& indent,
86 const std::string& name,
int vsize, iter v) {
88 for (ni = 0; ni < _level; ni++) {
91 s <<
"<" << XML_filter(name) <<
"> ";
96 for (j = 0; j < n5; j++) {
97 for (i = 0; i < 5; i++) {
98 s << v[k] << (k < n - 1 ?
", " :
"");
103 for (ni = 0; ni < _level; ni++) {
108 for (i = k; i < n; i++) {
109 s << v[k] << (k < n - 1 ?
", " :
"");
113 s <<
"</" << XML_filter(name) <<
">" << std::endl;