annotate base/XmlExportable.cpp @ 61:749b5521e082

* adjust for latency if the plugin reports it
author Chris Cannam
date Mon, 27 Mar 2006 16:15:19 +0000
parents d397ea0a79f5
children ea730e3f9ace
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@3 16 #include "XmlExportable.h"
Chris@4 17 #include <map>
Chris@3 18
Chris@3 19 QString
Chris@3 20 XmlExportable::encodeEntities(QString s)
Chris@3 21 {
Chris@3 22 s
Chris@3 23 .replace("&", "&amp;")
Chris@3 24 .replace("<", "&lt;")
Chris@3 25 .replace(">", "&gt;")
Chris@3 26 .replace("\"", "&quot;")
Chris@3 27 .replace("'", "&apos;");
Chris@3 28
Chris@3 29 return s;
Chris@3 30 }
Chris@3 31
Chris@3 32 QString
Chris@3 33 XmlExportable::encodeColour(QColor c)
Chris@3 34 {
Chris@3 35 QString r, g, b;
Chris@3 36
Chris@3 37 r.setNum(c.red(), 16);
Chris@3 38 if (c.red() < 16) r = "0" + r;
Chris@3 39
Chris@3 40 g.setNum(c.green(), 16);
Chris@3 41 if (c.green() < 16) g = "0" + g;
Chris@3 42
Chris@3 43 b.setNum(c.blue(), 16);
Chris@3 44 if (c.blue() < 16) b = "0" + b;
Chris@3 45
Chris@3 46 return "#" + r + g + b;
Chris@3 47 }
Chris@3 48
Chris@4 49 int
Chris@4 50 XmlExportable::getObjectExportId(const void * object)
Chris@4 51 {
Chris@4 52 static std::map<const void *, int> idMap;
Chris@4 53 static int maxId = 0;
Chris@4 54
Chris@4 55 if (idMap.find(object) == idMap.end()) {
Chris@4 56 idMap[object] = maxId++;
Chris@4 57 }
Chris@4 58
Chris@4 59 return idMap[object];
Chris@4 60 }
Chris@4 61
Chris@4 62