From b968ea8ed364238c57c3e74cf2c122cb897cfbea Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 23 May 2017 19:13:13 +0200 Subject: Builds but doesn't link, no formatters yet --- .../domain/mimetreeparser/otp/queuehtmlwriter.cpp | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 framework/src/domain/mimetreeparser/otp/queuehtmlwriter.cpp (limited to 'framework/src/domain/mimetreeparser/otp/queuehtmlwriter.cpp') diff --git a/framework/src/domain/mimetreeparser/otp/queuehtmlwriter.cpp b/framework/src/domain/mimetreeparser/otp/queuehtmlwriter.cpp new file mode 100644 index 00000000..ea17bf5c --- /dev/null +++ b/framework/src/domain/mimetreeparser/otp/queuehtmlwriter.cpp @@ -0,0 +1,136 @@ +/* + Copyright (c) 2015 Sandro Knauß + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#include "queuehtmlwriter.h" + +#include "mimetreeparser_debug.h" + +#include +#include + +using namespace MimeTreeParser; + +QueueHtmlWriter::QueueHtmlWriter(HtmlWriter *base) + : HtmlWriter() + , mBase(base) +{ +} + +QueueHtmlWriter::~QueueHtmlWriter() +{ +} + +void QueueHtmlWriter::setBase(HtmlWriter *base) +{ + mBase = base; +} + +void QueueHtmlWriter::begin(const QString &css) +{ + Command cmd; + cmd.type = Command::Begin; + cmd.s = css; + mQueue.append(cmd); +} + +void QueueHtmlWriter::end() +{ + Command cmd; + cmd.type = Command::End; + mQueue.append(cmd); +} + +void QueueHtmlWriter::reset() +{ + Command cmd; + cmd.type = Command::Reset; + mQueue.append(cmd); +} + +void QueueHtmlWriter::write(const QString &str) +{ + Command cmd; + cmd.type = Command::Write; + cmd.s = str; + mQueue.append(cmd); +} + +void QueueHtmlWriter::queue(const QString &str) +{ + Command cmd; + cmd.type = Command::Queue; + cmd.s = str; + mQueue.append(cmd); +} + +void QueueHtmlWriter::flush() +{ + Command cmd; + cmd.type = Command::Flush; + mQueue.append(cmd); +} + +void QueueHtmlWriter::replay() +{ + foreach (const auto &entry, mQueue) { + switch (entry.type) { + case Command::Begin: + mBase->begin(entry.s); + break; + case Command::End: + mBase->end(); + break; + case Command::Reset: + mBase->reset(); + break; + case Command::Write: + mBase->write(entry.s); + break; + case Command::Queue: + mBase->queue(entry.s); + break; + case Command::Flush: + mBase->flush(); + break; + case Command::EmbedPart: + mBase->embedPart(entry.b, entry.s); + break; + case Command::ExtraHead: + mBase->extraHead(entry.s); + break; + } + } +} + +void QueueHtmlWriter::embedPart(const QByteArray &contentId, const QString &url) +{ + Command cmd; + cmd.type = Command::EmbedPart; + cmd.s = url; + cmd.b = contentId; + mQueue.append(cmd); +} +void QueueHtmlWriter::extraHead(const QString &extra) +{ + Command cmd; + cmd.type = Command::ExtraHead; + cmd.s = extra; + mQueue.append(cmd); +} + -- cgit v1.2.3