X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=libs%2Fxml%2Fxmlwriter.h;h=d387f3200fa903d73d58ad107eeb5100fe9321df;hp=8cf40bddf5b22e555674fe9b597355147057c705;hb=8c19a03806d0a06596036625adaacced47c44431;hpb=eaad87408fc96eb1353f645543e2cc8f632b4ed1 diff --git a/libs/xml/xmlwriter.h b/libs/xml/xmlwriter.h index 8cf40bdd..d387f320 100644 --- a/libs/xml/xmlwriter.h +++ b/libs/xml/xmlwriter.h @@ -26,57 +26,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "xml/ixml.h" -class BufferedTextOutputStream : public TextOutputStream -{ - static const int m_bufsize = 1024; - TextOutputStream& m_ostream; - char m_buffer[m_bufsize]; - char* m_pos; - const char* m_end; - - const char* end() const - { - return m_end; - } - void reset() - { - m_pos = m_buffer; - } - void flush() - { - m_ostream.write(m_buffer, m_pos - m_buffer); - reset(); - } -public: - BufferedTextOutputStream(TextOutputStream& ostream) : m_ostream(ostream), m_pos(m_buffer), m_end(m_buffer+m_bufsize) - { - } - ~BufferedTextOutputStream() - { - flush(); - } - void write(const char c) - { - if(m_pos == end()) - { - flush(); - } - *m_pos++ = c; - } - std::size_t write(const char* buffer, std::size_t length) - { - const char*const end = buffer + length; - for(const char* p = buffer; p != end; ++p) - { - write(*p); - } - return length; - } -}; - class XMLEntityOutputStream { - BufferedTextOutputStream m_ostream; + SingleCharacterOutputStream m_ostream; public: XMLEntityOutputStream(TextOutputStream& ostream) : m_ostream(ostream)