Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@3: Chris@3: /* Chris@52: Sonic Visualiser Chris@52: An audio file viewer and annotation editor. Chris@52: Centre for Digital Music, Queen Mary, University of London. Chris@52: This file copyright 2006 Chris Cannam. Chris@3: Chris@52: This program is free software; you can redistribute it and/or Chris@52: modify it under the terms of the GNU General Public License as Chris@52: published by the Free Software Foundation; either version 2 of the Chris@52: License, or (at your option) any later version. See the file Chris@52: COPYING included with this distribution for more information. Chris@3: */ Chris@3: Chris@3: #ifndef _XML_EXPORTABLE_H_ Chris@3: #define _XML_EXPORTABLE_H_ Chris@3: Chris@3: #include Chris@3: #include Chris@3: Chris@123: class QTextStream; Chris@123: Chris@3: class XmlExportable Chris@3: { Chris@3: public: Chris@27: virtual ~XmlExportable() { } Chris@27: Chris@123: /** Chris@123: * Stream this exportable object out to XML on a text stream. Chris@123: * Chris@123: * The default implementation calls toXmlString and streams the Chris@123: * resulting string. This is only appropriate for objects with Chris@123: * short representations. Bigger objects should override this Chris@123: * method so as to write to the stream directly and override Chris@123: * toXmlString with a method that calls this one, so that the Chris@123: * direct streaming method can be used when appropriate. Chris@123: */ Chris@123: virtual void toXml(QTextStream &stream, Chris@123: QString indent = "", Chris@123: QString extraAttributes = "") const; Chris@123: Chris@123: /** Chris@123: * Convert this exportable object to XML in a string. Chris@123: */ Chris@3: virtual QString toXmlString(QString indent = "", Chris@3: QString extraAttributes = "") const = 0; Chris@3: Chris@3: static QString encodeEntities(QString); Chris@3: Chris@3: static QString encodeColour(QColor); Chris@4: Chris@85: static int getObjectExportId(const void *); // thread-safe Chris@3: }; Chris@3: Chris@3: #endif