60 virtual void write(
const char* buffer, std::size_t
n) = 0;
69 void puts(
const char (&str)[
n]) { write(
str,
n-1); }
77 virtual void put(
char c) { write(&c, 1); }
103 bool attributesStillAlowed;
156 std::size_t getLevel()
const;
164 Element& attr(
const std::string& attr_name,
const std::string& attr_value);
172 template <
typename ValueT>
173 Element&
attr(
const std::string& attr_name,
const ValueT& attr_value) {
174 return attr(attr_name,
str(attr_value));
182 Element& writeText(
const char* str);
198 return writeText(
str(value));
201 Element& writeCDATA(
const std::string& str);
212 template <
typename name_t>
219 template <
typename name_t>
238 bool isCurrent()
const {
return writer->current ==
this; }
250 const std::string&
getName()
const {
return name; }
269 bool disallowAttributes();
271 void ensureIsCurrent();
279 void appendStr(
const std::string& s) { out->write(s.data(), s.size()); }
281 void appendStrQuoted(
const char* s);
283 void appendStrQuoted(
const std::string& s) { appendStrQuoted(s.c_str()); }
289 std::size_t indentation;
298 XMLWriter(std::ostream& out, std::size_t indentation=2);
305 XMLWriter(
const std::string&
file_name, std::size_t indentation=2);
314 XMLWriter(std::FILE*
cfile, std::size_t indentation=2);
321 XMLWriter(Output* out, std::size_t indentation=2);
328 out->puts(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>");
337 template <
typename name_t>
345 template <
typename name_t>
352 template <
typename text_t>
355 current->writeText(std::forward<text_t>(text));
362 template <
typename text_t>
365 current->writeCDATA(std::forward<text_t>(
cdata));
372 if (current) current->indent();