annotate base/XmlExportable.cpp @ 33:51e158b505da
* Rearrange spectrogram cacheing so that gain, normalization, instantaneous
frequency calculations etc can be done from the cached data (increasing the
size of the cache, but also the usability).
author |
Chris Cannam |
date |
Thu, 23 Feb 2006 18:01:31 +0000 |
parents |
149bb02a41ba |
children |
39ae3dee27b9 |
rev |
line source |
Chris@3
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@3
|
2
|
Chris@3
|
3 /*
|
Chris@3
|
4 A waveform viewer and audio annotation editor.
|
Chris@3
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@3
|
6
|
Chris@3
|
7 This is experimental software. Not for distribution.
|
Chris@3
|
8 */
|
Chris@3
|
9
|
Chris@3
|
10 #include "XmlExportable.h"
|
Chris@4
|
11 #include <map>
|
Chris@3
|
12
|
Chris@3
|
13 QString
|
Chris@3
|
14 XmlExportable::encodeEntities(QString s)
|
Chris@3
|
15 {
|
Chris@3
|
16 s
|
Chris@3
|
17 .replace("&", "&")
|
Chris@3
|
18 .replace("<", "<")
|
Chris@3
|
19 .replace(">", ">")
|
Chris@3
|
20 .replace("\"", """)
|
Chris@3
|
21 .replace("'", "'");
|
Chris@3
|
22
|
Chris@3
|
23 return s;
|
Chris@3
|
24 }
|
Chris@3
|
25
|
Chris@3
|
26 QString
|
Chris@3
|
27 XmlExportable::encodeColour(QColor c)
|
Chris@3
|
28 {
|
Chris@3
|
29 QString r, g, b;
|
Chris@3
|
30
|
Chris@3
|
31 r.setNum(c.red(), 16);
|
Chris@3
|
32 if (c.red() < 16) r = "0" + r;
|
Chris@3
|
33
|
Chris@3
|
34 g.setNum(c.green(), 16);
|
Chris@3
|
35 if (c.green() < 16) g = "0" + g;
|
Chris@3
|
36
|
Chris@3
|
37 b.setNum(c.blue(), 16);
|
Chris@3
|
38 if (c.blue() < 16) b = "0" + b;
|
Chris@3
|
39
|
Chris@3
|
40 return "#" + r + g + b;
|
Chris@3
|
41 }
|
Chris@3
|
42
|
Chris@4
|
43 int
|
Chris@4
|
44 XmlExportable::getObjectExportId(const void * object)
|
Chris@4
|
45 {
|
Chris@4
|
46 static std::map<const void *, int> idMap;
|
Chris@4
|
47 static int maxId = 0;
|
Chris@4
|
48
|
Chris@4
|
49 if (idMap.find(object) == idMap.end()) {
|
Chris@4
|
50 idMap[object] = maxId++;
|
Chris@4
|
51 }
|
Chris@4
|
52
|
Chris@4
|
53 return idMap[object];
|
Chris@4
|
54 }
|
Chris@4
|
55
|
Chris@4
|
56
|