annotate base/XmlExportable.h @ 1886:f803d3c33f76 tip

Switch off copious debug in soft synth driving
author Chris Cannam
date Fri, 14 Aug 2020 10:44:44 +0100
parents d0ef65d8dd89
children
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@3 2
Chris@3 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@3 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@3 14 */
Chris@3 15
Chris@1581 16 #ifndef SV_XML_EXPORTABLE_H
Chris@1581 17 #define SV_XML_EXPORTABLE_H
Chris@3 18
Chris@3 19 #include <QString>
Chris@3 20
Chris@686 21 #include "Debug.h"
Chris@686 22
Chris@123 23 class QTextStream;
Chris@123 24
Chris@3 25 class XmlExportable
Chris@3 26 {
Chris@3 27 public:
Chris@1738 28 enum {
Chris@1738 29 // The value NO_ID (-1) is never allocated as an export id
Chris@1738 30 NO_ID = -1
Chris@1738 31 };
Chris@1738 32
Chris@1750 33 typedef int ExportId;
Chris@1750 34
Chris@1738 35 XmlExportable() : m_exportId(NO_ID) { }
Chris@27 36 virtual ~XmlExportable() { }
Chris@27 37
Chris@123 38 /**
Chris@1677 39 * Return the numerical export identifier for this object. It's
Chris@1677 40 * allocated the first time this is called, so objects on which
Chris@1677 41 * this is never called do not get allocated one.
Chris@1677 42 */
Chris@1750 43 ExportId getExportId() const;
Chris@1677 44
Chris@1677 45 /**
Chris@123 46 * Stream this exportable object out to XML on a text stream.
Chris@123 47 */
Chris@123 48 virtual void toXml(QTextStream &stream,
Chris@123 49 QString indent = "",
Chris@314 50 QString extraAttributes = "") const = 0;
Chris@123 51
Chris@123 52 /**
Chris@314 53 * Convert this exportable object to XML in a string. The default
Chris@314 54 * implementation calls toXml and returns the result as a string.
Chris@314 55 * Do not override this unless you really know what you're doing.
Chris@123 56 */
Chris@3 57 virtual QString toXmlString(QString indent = "",
Chris@1429 58 QString extraAttributes = "") const;
Chris@3 59
Chris@3 60 static QString encodeEntities(QString);
Chris@3 61
Chris@387 62 static QString encodeColour(int r, int g, int b);
Chris@4 63
Chris@1677 64 private:
Chris@1677 65 mutable int m_exportId;
Chris@3 66 };
Chris@3 67
Chris@3 68 #endif