Chris@3: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@3: Chris@3: /* Chris@3: A waveform viewer and audio annotation editor. Chris@3: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@3: Chris@3: This is experimental software. Not for distribution. Chris@3: */ Chris@3: Chris@3: #include "XmlExportable.h" Chris@4: #include Chris@3: Chris@3: QString Chris@3: XmlExportable::encodeEntities(QString s) Chris@3: { Chris@3: s Chris@3: .replace("&", "&") Chris@3: .replace("<", "<") Chris@3: .replace(">", ">") Chris@3: .replace("\"", """) Chris@3: .replace("'", "'"); Chris@3: Chris@3: return s; Chris@3: } Chris@3: Chris@3: QString Chris@3: XmlExportable::encodeColour(QColor c) Chris@3: { Chris@3: QString r, g, b; Chris@3: Chris@3: r.setNum(c.red(), 16); Chris@3: if (c.red() < 16) r = "0" + r; Chris@3: Chris@3: g.setNum(c.green(), 16); Chris@3: if (c.green() < 16) g = "0" + g; Chris@3: Chris@3: b.setNum(c.blue(), 16); Chris@3: if (c.blue() < 16) b = "0" + b; Chris@3: Chris@3: return "#" + r + g + b; Chris@3: } Chris@3: Chris@4: int Chris@4: XmlExportable::getObjectExportId(const void * object) Chris@4: { Chris@4: static std::map idMap; Chris@4: static int maxId = 0; Chris@4: Chris@4: if (idMap.find(object) == idMap.end()) { Chris@4: idMap[object] = maxId++; Chris@4: } Chris@4: Chris@4: return idMap[object]; Chris@4: } Chris@4: Chris@4: