diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2019-07-23 15:45:29 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2019-07-31 13:12:01 +0000 |
commit | 86747ff36bb162764fd8c2f741a1674d16b0b3cd (patch) | |
tree | ebc9323f57c601ae49af9cff9fe0674fd71bb6ca /src/plugins/generator/iarew/iarewworkspacewriter.cpp | |
parent | 2363f13f8fbd001a3544acb2a600010893e4cf80 (diff) |
baremetal: Share common generators code
Common code which are used for the 'iarew' and 'keiluv'
generators was moved to the corelib/generators library.
Besides, this code also can be used in future for the
XML-based generators.
Change-Id: I79a21e3e078d563600d7f365785731fe9e847045
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/generator/iarew/iarewworkspacewriter.cpp')
-rw-r--r-- | src/plugins/generator/iarew/iarewworkspacewriter.cpp | 51 |
1 files changed, 5 insertions, 46 deletions
diff --git a/src/plugins/generator/iarew/iarewworkspacewriter.cpp b/src/plugins/generator/iarew/iarewworkspacewriter.cpp index bf7cdee75..8b56b7c54 100644 --- a/src/plugins/generator/iarew/iarewworkspacewriter.cpp +++ b/src/plugins/generator/iarew/iarewworkspacewriter.cpp @@ -28,66 +28,25 @@ ** ****************************************************************************/ -#include "iarewproperty.h" -#include "iarewpropertygroup.h" -#include "iarewworkspace.h" #include "iarewworkspacewriter.h" -#include <ostream> - namespace qbs { IarewWorkspaceWriter::IarewWorkspaceWriter(std::ostream *device) - : m_device(device) -{ - m_writer.reset(new QXmlStreamWriter(&m_buffer)); - m_writer->setAutoFormatting(true); -} - -bool IarewWorkspaceWriter::write(const IarewWorkspace *workspace) + : gen::xml::WorkspaceWriter(device) { - m_buffer.clear(); - m_writer->writeStartDocument(); - workspace->accept(this); - m_writer->writeEndDocument(); - if (m_writer->hasError()) - return false; - m_device->write(&*std::begin(m_buffer), m_buffer.size()); - return m_device->good(); } -void IarewWorkspaceWriter::visitStart(const IarewWorkspace *workspace) +void IarewWorkspaceWriter::visitStart(const gen::xml::Workspace *workspace) { Q_UNUSED(workspace) - m_writer->writeStartElement(QStringLiteral("workspace")); + writer()->writeStartElement(QStringLiteral("workspace")); } -void IarewWorkspaceWriter::visitEnd(const IarewWorkspace *workspace) +void IarewWorkspaceWriter::visitEnd(const gen::xml::Workspace *workspace) { Q_UNUSED(workspace) - m_writer->writeEndElement(); -} - -void IarewWorkspaceWriter::visitStart(const IarewProperty *property) -{ - const QString stringValue = property->value().toString(); - m_writer->writeTextElement(QString::fromLatin1(property->name()), stringValue); -} - -void IarewWorkspaceWriter::visitEnd(const IarewProperty *property) -{ - Q_UNUSED(property) -} - -void IarewWorkspaceWriter::visitStart(const IarewPropertyGroup *propertyGroup) -{ - m_writer->writeStartElement(QString::fromLatin1(propertyGroup->name())); -} - -void IarewWorkspaceWriter::visitEnd(const IarewPropertyGroup *propertyGroup) -{ - Q_UNUSED(propertyGroup) - m_writer->writeEndElement(); + writer()->writeEndElement(); } } // namespace qbs |