kwave  18.07.70
WavPropertyMap.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  WavPropertyMap.cpp - map for translating properties to chunk names
3  -------------------
4  begin : Sat Jul 06 2002
5  copyright : (C) 2002 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "WavPropertyMap.h"
19 
20 //***************************************************************************
22 {
23  // NOTE #1: the left column is allowed to have multiple entries with the
24  // same property, when encoding the first one is used, when
25  // decoding, the other ones serve as alternatives
26  // NOTE #2: the chunk names in the right column must be *unique* !
27  // well-known tags
28  insert(Kwave::INF_AUTHOR ,"AUTH"); // author's name
29  insert(Kwave::INF_ANNOTATION ,"ANNO"); // annotations
30  insert(Kwave::INF_ARCHIVAL ,"IARL"); // archival location (EXIF 2.3)
31  insert(Kwave::INF_PERFORMER ,"IART"); // performer (EXIF 2.3)
32  insert(Kwave::INF_COMMISSIONED ,"ICMS"); // commissioned (EXIF 2.3)
33  insert(Kwave::INF_COMMENTS ,"ICMT"); // comments (EXIF 2.3)
34  insert(Kwave::INF_COPYRIGHT ,"ICOP"); // copyright (EXIF 2.3)
35  insert(Kwave::INF_CREATION_DATE ,"ICRD"); // creation date (iso) (EXIF 2.3)
36  insert(Kwave::INF_ENGINEER ,"IENG"); // engineer (EXIF 2.3)
37  insert(Kwave::INF_GENRE ,"IGNR"); // genre (EXIF 2.3)
38  insert(Kwave::INF_KEYWORDS ,"IKEY"); // keywords (EXIF 2.3)
39  insert(Kwave::INF_MEDIUM ,"IMED"); // medium (EXIF 2.3)
40  insert(Kwave::INF_NAME ,"INAM"); // name (EXIF 2.3)
41  insert(Kwave::INF_PRODUCT ,"IPRD"); // product (EXIF 2.3)
42  insert(Kwave::INF_SOFTWARE ,"ISFT"); // software (EXIF 2.3)
43  insert(Kwave::INF_SOURCE ,"ISRC"); // source (EXIF 2.3)
44  insert(Kwave::INF_SOURCE_FORM ,"ISRF"); // source form (EXIF 2.3)
45  insert(Kwave::INF_TECHNICAN ,"ITCH"); // technician (EXIF 2.3)
46  insert(Kwave::INF_SUBJECT ,"ISBJ"); // subject (EXIF 2.3)
47 
48  // tags from SoundForge Pro
49  insert(Kwave::INF_TRACK ,"TRCK"); // track number
50  insert(Kwave::INF_VERSION ,"TVER"); // version/remix
51  insert(Kwave::INF_ORGANIZATION ,"TORG"); // organization/label
52 
53  // some others, alternatives
54  insert(Kwave::INF_ALBUM ,"IALB"); // name of the album
55  insert(Kwave::INF_COPYRIGHT ,"(c) "); // copyright
56  insert(Kwave::INF_CREATION_DATE ,"DTIM"); // date/time original
57  insert(Kwave::INF_CREATION_DATE ,"YEAR"); // year (MovieID ref12)
58  insert(Kwave::INF_GENRE ,"GENR"); // genre (MovieID ref12)
59  insert(Kwave::INF_GENRE ,"ISGN"); // second genre (IMDB)
60  insert(Kwave::INF_AUTHOR ,"IWRI"); // written by (IMDB)
61  insert(Kwave::INF_ENGINEER ,"IEDT"); // edited by (IMDB)
62  insert(Kwave::INF_CD ,"IPTR"); // part (?)
63 
64  // non-standard, probably only known by Kwave
65  insert(Kwave::INF_CONTACT ,"cnt "); // contact information for creator
66  insert(Kwave::INF_ISRC ,"isrc"); // International Standard Recording Code
67  insert(Kwave::INF_LICENSE ,"lic "); // license information
68 }
69 
70 //***************************************************************************
72  const QByteArray &chunk)
73 {
74  Pair p(property, chunk);
75  append(p);
76 }
77 
78 //***************************************************************************
80  const Kwave::FileProperty property) const
81 {
82  foreach(const Pair &p, QList<Pair>(*this)) {
83  if (p.first == property)
84  return p.second;
85  }
86  return "";
87 }
88 
89 //***************************************************************************
91  const Kwave::FileProperty property) const
92 {
93  foreach(const Pair &p, QList<Pair>(*this)) {
94  if (p.first == property)
95  return true;
96  }
97  return false;
98 }
99 
100 //***************************************************************************
101 bool Kwave::WavPropertyMap::containsChunk(const QByteArray &chunk) const
102 {
103  foreach(const Pair &p, QList<Pair>(*this)) {
104  if (p.second == chunk)
105  return true;
106  }
107  return false;
108 }
109 
110 //***************************************************************************
111 QList<QByteArray> Kwave::WavPropertyMap::chunks() const
112 {
113  QList<QByteArray> list;
114  foreach(const Pair &p, QList<Pair>(*this)) {
115  if (!list.contains(p.second))
116  list.append(p.second);
117  }
118  return list;
119 }
120 
121 //***************************************************************************
123  const QByteArray &chunk) const
124 {
125  foreach(const Pair &p, QList<Pair>(*this)) {
126  if (p.second == chunk) return p.first;
127  }
128  return static_cast<Kwave::FileProperty>(-1);
129 }
130 
131 //***************************************************************************
132 QList<Kwave::FileProperty> Kwave::WavPropertyMap::properties() const
133 {
134  QList<Kwave::FileProperty> list;
135  foreach(const Pair &p, QList<Pair>(*this)) {
136  if (!list.contains(p.first))
137  list.append(p.first);
138  }
139  return list;
140 }
141 
142 //***************************************************************************
143 //***************************************************************************
QByteArray findProperty(const Kwave::FileProperty property) const
Kwave::FileProperty property(const QByteArray &chunk) const
bool containsProperty(const Kwave::FileProperty property) const
void insert(const Kwave::FileProperty property, const QByteArray &chunk)
QList< Kwave::FileProperty > properties() const
QPair< Kwave::FileProperty, QByteArray > Pair
FileProperty
Definition: FileInfo.h:45
bool containsChunk(const QByteArray &chunk) const
QList< QByteArray > chunks() const