[cstdstring] remove CStdString::Empty and replace with std::string::clear
[vuplus_xbmc] / xbmc / music / tags / MusicInfoTag.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "MusicInfoTag.h"
22 #include "music/Album.h"
23 #include "music/Artist.h"
24 #include "utils/StringUtils.h"
25 #include "settings/AdvancedSettings.h"
26 #include "utils/Variant.h"
27
28 using namespace MUSIC_INFO;
29
30 EmbeddedArtInfo::EmbeddedArtInfo(size_t siz, const std::string &mim)
31 {
32   set(siz, mim);
33 }
34
35 void EmbeddedArtInfo::set(size_t siz, const std::string &mim)
36 {
37   size = siz;
38   mime = mim;
39 }
40
41 void EmbeddedArtInfo::clear()
42 {
43   mime.clear();
44   size = 0;
45 }
46
47 bool EmbeddedArtInfo::empty() const
48 {
49   return size == 0;
50 }
51
52 bool EmbeddedArtInfo::matches(const EmbeddedArtInfo &right) const
53 {
54   return (size == right.size &&
55           mime == right.mime);
56 }
57
58 EmbeddedArt::EmbeddedArt(const uint8_t *dat, size_t siz, const std::string &mim)
59 {
60   set(dat, siz, mim);
61 }
62
63 void EmbeddedArt::set(const uint8_t *dat, size_t siz, const std::string &mim)
64 {
65   EmbeddedArtInfo::set(siz, mim);
66   data.resize(siz);
67   memcpy(&data[0], dat, siz);
68 }
69
70 CMusicInfoTag::CMusicInfoTag(void)
71 {
72   Clear();
73 }
74
75 CMusicInfoTag::CMusicInfoTag(const CMusicInfoTag& tag)
76 {
77   *this = tag;
78 }
79
80 CMusicInfoTag::~CMusicInfoTag()
81 {}
82
83 const CMusicInfoTag& CMusicInfoTag::operator =(const CMusicInfoTag& tag)
84 {
85   if (this == &tag) return * this;
86
87   m_strURL = tag.m_strURL;
88   m_artist = tag.m_artist;
89   m_albumArtist = tag.m_albumArtist;
90   m_strAlbum = tag.m_strAlbum;
91   m_genre = tag.m_genre;
92   m_strTitle = tag.m_strTitle;
93   m_strMusicBrainzTrackID = tag.m_strMusicBrainzTrackID;
94   m_musicBrainzArtistID = tag.m_musicBrainzArtistID;
95   m_strMusicBrainzAlbumID = tag.m_strMusicBrainzAlbumID;
96   m_musicBrainzAlbumArtistID = tag.m_musicBrainzAlbumArtistID;
97   m_strMusicBrainzTRMID = tag.m_strMusicBrainzTRMID;
98   m_strComment = tag.m_strComment;
99   m_strLyrics = tag.m_strLyrics;
100   m_lastPlayed = tag.m_lastPlayed;
101   m_bCompilation = tag.m_bCompilation;
102   m_iDuration = tag.m_iDuration;
103   m_iTrack = tag.m_iTrack;
104   m_bLoaded = tag.m_bLoaded;
105   m_rating = tag.m_rating;
106   m_listeners = tag.m_listeners;
107   m_iTimesPlayed = tag.m_iTimesPlayed;
108   m_iDbId = tag.m_iDbId;
109   m_type = tag.m_type;
110   m_iAlbumId = tag.m_iAlbumId;
111   m_iTrackGain = tag.m_iTrackGain;
112   m_iAlbumGain = tag.m_iAlbumGain;
113   m_fTrackPeak = tag.m_fTrackPeak;
114   m_fAlbumPeak = tag.m_fAlbumPeak;
115   m_iHasGainInfo = tag.m_iHasGainInfo;
116
117   memcpy(&m_dwReleaseDate, &tag.m_dwReleaseDate, sizeof(m_dwReleaseDate) );
118   m_coverArt = tag.m_coverArt;
119   return *this;
120 }
121
122 bool CMusicInfoTag::operator !=(const CMusicInfoTag& tag) const
123 {
124   if (this == &tag) return false;
125   if (m_strURL != tag.m_strURL) return true;
126   if (m_strTitle != tag.m_strTitle) return true;
127   if (m_bCompilation != tag.m_bCompilation) return true;
128   if (m_artist != tag.m_artist) return true;
129   if (m_albumArtist != tag.m_albumArtist) return true;
130   if (m_strAlbum != tag.m_strAlbum) return true;
131   if (m_iDuration != tag.m_iDuration) return true;
132   if (m_iTrack != tag.m_iTrack) return true;
133   return false;
134 }
135
136 int CMusicInfoTag::GetTrackNumber() const
137 {
138   return (m_iTrack & 0xffff);
139 }
140
141 int CMusicInfoTag::GetDiscNumber() const
142 {
143   return (m_iTrack >> 16);
144 }
145
146 int CMusicInfoTag::GetTrackAndDiskNumber() const
147 {
148   return m_iTrack;
149 }
150
151 int CMusicInfoTag::GetDuration() const
152 {
153   return m_iDuration;
154 }
155
156 const CStdString& CMusicInfoTag::GetTitle() const
157 {
158   return m_strTitle;
159 }
160
161 const CStdString& CMusicInfoTag::GetURL() const
162 {
163   return m_strURL;
164 }
165
166 const std::vector<std::string>& CMusicInfoTag::GetArtist() const
167 {
168   return m_artist;
169 }
170
171 const CStdString& CMusicInfoTag::GetAlbum() const
172 {
173   return m_strAlbum;
174 }
175
176 int CMusicInfoTag::GetAlbumId() const
177 {
178   return m_iAlbumId;
179 }
180
181 const std::vector<std::string>& CMusicInfoTag::GetAlbumArtist() const
182 {
183   return m_albumArtist;
184 }
185
186 const std::vector<std::string>& CMusicInfoTag::GetGenre() const
187 {
188   return m_genre;
189 }
190
191 void CMusicInfoTag::GetReleaseDate(SYSTEMTIME& dateTime) const
192 {
193   memcpy(&dateTime, &m_dwReleaseDate, sizeof(m_dwReleaseDate) );
194 }
195
196 int CMusicInfoTag::GetYear() const
197 {
198   return m_dwReleaseDate.wYear;
199 }
200
201 int CMusicInfoTag::GetDatabaseId() const
202 {
203   return m_iDbId;
204 }
205
206 const std::string &CMusicInfoTag::GetType() const
207 {
208   return m_type;
209 }
210
211 CStdString CMusicInfoTag::GetYearString() const
212 {
213   return m_dwReleaseDate.wYear ? StringUtils::Format("%i", m_dwReleaseDate.wYear) : StringUtils::Empty;
214 }
215
216 const CStdString &CMusicInfoTag::GetComment() const
217 {
218   return m_strComment;
219 }
220
221 const CStdString &CMusicInfoTag::GetLyrics() const
222 {
223   return m_strLyrics;
224 }
225
226 char CMusicInfoTag::GetRating() const
227 {
228   return m_rating;
229 }
230
231 int CMusicInfoTag::GetListeners() const
232 {
233  return m_listeners;
234 }
235
236 int CMusicInfoTag::GetPlayCount() const
237 {
238   return m_iTimesPlayed;
239 }
240
241 const CDateTime &CMusicInfoTag::GetLastPlayed() const
242 {
243   return m_lastPlayed;
244 }
245
246 bool CMusicInfoTag::GetCompilation() const
247 {
248   return m_bCompilation;
249 }
250
251 const EmbeddedArtInfo &CMusicInfoTag::GetCoverArtInfo() const
252 {
253   return m_coverArt;
254 }
255
256 int CMusicInfoTag::GetReplayGainTrackGain() const
257 {
258   return m_iTrackGain;
259 }
260
261 int CMusicInfoTag::GetReplayGainAlbumGain() const
262 {
263   return m_iAlbumGain;
264 }
265
266 float CMusicInfoTag::GetReplayGainTrackPeak() const
267 {
268   return m_fTrackPeak;
269 }
270
271 float CMusicInfoTag::GetReplayGainAlbumPeak() const
272 {
273   return m_fAlbumPeak;
274 }
275
276 int CMusicInfoTag::HasReplayGainInfo() const
277 {
278   return m_iHasGainInfo;
279 }
280
281 void CMusicInfoTag::SetURL(const CStdString& strURL)
282 {
283   m_strURL = strURL;
284 }
285
286 void CMusicInfoTag::SetTitle(const CStdString& strTitle)
287 {
288   m_strTitle = Trim(strTitle);
289 }
290
291 void CMusicInfoTag::SetArtist(const CStdString& strArtist)
292 {
293   if (!strArtist.empty())
294     SetArtist(StringUtils::Split(strArtist, g_advancedSettings.m_musicItemSeparator));
295   else
296     m_artist.clear();
297 }
298
299 void CMusicInfoTag::SetArtist(const std::vector<std::string>& artists)
300 {
301   m_artist = artists;
302 }
303
304 void CMusicInfoTag::SetAlbum(const CStdString& strAlbum)
305 {
306   m_strAlbum = Trim(strAlbum);
307 }
308
309 void CMusicInfoTag::SetAlbumId(const int iAlbumId)
310 {
311   m_iAlbumId = iAlbumId;
312 }
313
314 void CMusicInfoTag::SetAlbumArtist(const CStdString& strAlbumArtist)
315 {
316   if (!strAlbumArtist.empty())
317     SetAlbumArtist(StringUtils::Split(strAlbumArtist, g_advancedSettings.m_musicItemSeparator));
318   else
319     m_albumArtist.clear();
320 }
321
322 void CMusicInfoTag::SetAlbumArtist(const std::vector<std::string>& albumArtists)
323 {
324   m_albumArtist = albumArtists;
325 }
326
327 void CMusicInfoTag::SetGenre(const CStdString& strGenre)
328 {
329   if (!strGenre.empty())
330     SetGenre(StringUtils::Split(strGenre, g_advancedSettings.m_musicItemSeparator));
331   else
332     m_genre.clear();
333 }
334
335 void CMusicInfoTag::SetGenre(const std::vector<std::string>& genres)
336 {
337   m_genre = genres;
338 }
339
340 void CMusicInfoTag::SetYear(int year)
341 {
342   memset(&m_dwReleaseDate, 0, sizeof(m_dwReleaseDate) );
343   m_dwReleaseDate.wYear = year;
344 }
345
346 void CMusicInfoTag::SetDatabaseId(long id, const std::string &type)
347 {
348   m_iDbId = id;
349   m_type = type;
350 }
351
352 void CMusicInfoTag::SetReleaseDate(SYSTEMTIME& dateTime)
353 {
354   memcpy(&m_dwReleaseDate, &dateTime, sizeof(m_dwReleaseDate) );
355 }
356
357 void CMusicInfoTag::SetTrackNumber(int iTrack)
358 {
359   m_iTrack = (m_iTrack & 0xffff0000) | (iTrack & 0xffff);
360 }
361
362 void CMusicInfoTag::SetPartOfSet(int iPartOfSet)
363 {
364   m_iTrack = (m_iTrack & 0xffff) | (iPartOfSet << 16);
365 }
366
367 void CMusicInfoTag::SetTrackAndDiskNumber(int iTrackAndDisc)
368 {
369   m_iTrack=iTrackAndDisc;
370 }
371
372 void CMusicInfoTag::SetDuration(int iSec)
373 {
374   m_iDuration = iSec;
375 }
376
377 void CMusicInfoTag::SetComment(const CStdString& comment)
378 {
379   m_strComment = comment;
380 }
381
382 void CMusicInfoTag::SetLyrics(const CStdString& lyrics)
383 {
384   m_strLyrics = lyrics;
385 }
386
387 void CMusicInfoTag::SetRating(char rating)
388 {
389   m_rating = rating;
390 }
391
392 void CMusicInfoTag::SetListeners(int listeners)
393 {
394  m_listeners = listeners;
395 }
396
397 void CMusicInfoTag::SetPlayCount(int playcount)
398 {
399   m_iTimesPlayed = playcount;
400 }
401
402 void CMusicInfoTag::SetLastPlayed(const CStdString& lastplayed)
403 {
404   m_lastPlayed.SetFromDBDateTime(lastplayed);
405 }
406
407 void CMusicInfoTag::SetLastPlayed(const CDateTime& lastplayed)
408 {
409   m_lastPlayed = lastplayed;
410 }
411
412 void CMusicInfoTag::SetCompilation(bool compilation)
413 {
414   m_bCompilation = compilation;
415 }
416
417 void CMusicInfoTag::SetLoaded(bool bOnOff)
418 {
419   m_bLoaded = bOnOff;
420 }
421
422 bool CMusicInfoTag::Loaded() const
423 {
424   return m_bLoaded;
425 }
426
427 const CStdString& CMusicInfoTag::GetMusicBrainzTrackID() const
428 {
429   return m_strMusicBrainzTrackID;
430 }
431
432 const std::vector<std::string>& CMusicInfoTag::GetMusicBrainzArtistID() const
433 {
434   return m_musicBrainzArtistID;
435 }
436
437 const CStdString& CMusicInfoTag::GetMusicBrainzAlbumID() const
438 {
439   return m_strMusicBrainzAlbumID;
440 }
441
442 const std::vector<std::string>& CMusicInfoTag::GetMusicBrainzAlbumArtistID() const
443 {
444   return m_musicBrainzAlbumArtistID;
445 }
446
447 const CStdString& CMusicInfoTag::GetMusicBrainzTRMID() const
448 {
449   return m_strMusicBrainzTRMID;
450 }
451
452 void CMusicInfoTag::SetMusicBrainzTrackID(const CStdString& strTrackID)
453 {
454   m_strMusicBrainzTrackID=strTrackID;
455 }
456
457 void CMusicInfoTag::SetMusicBrainzArtistID(const std::vector<std::string>& musicBrainzArtistId)
458 {
459   m_musicBrainzArtistID = musicBrainzArtistId;
460 }
461
462 void CMusicInfoTag::SetMusicBrainzAlbumID(const CStdString& strAlbumID)
463 {
464   m_strMusicBrainzAlbumID=strAlbumID;
465 }
466
467 void CMusicInfoTag::SetMusicBrainzAlbumArtistID(const std::vector<std::string>& musicBrainzAlbumArtistId)
468 {
469   m_musicBrainzAlbumArtistID = musicBrainzAlbumArtistId;
470 }
471
472 void CMusicInfoTag::SetMusicBrainzTRMID(const CStdString& strTRMID)
473 {
474   m_strMusicBrainzTRMID=strTRMID;
475 }
476
477 void CMusicInfoTag::SetCoverArtInfo(size_t size, const std::string &mimeType)
478 {
479   m_coverArt.set(size, mimeType);
480 }
481
482 void CMusicInfoTag::SetReplayGainTrackGain(int trackGain)
483 {
484   m_iTrackGain = trackGain;
485   m_iHasGainInfo |= REPLAY_GAIN_HAS_TRACK_INFO;
486 }
487
488 void CMusicInfoTag::SetReplayGainAlbumGain(int albumGain)
489 {
490   m_iAlbumGain = albumGain;
491   m_iHasGainInfo |= REPLAY_GAIN_HAS_ALBUM_INFO;
492 }
493
494 void CMusicInfoTag::SetReplayGainTrackPeak(float trackPeak)
495 {
496   m_fTrackPeak = trackPeak;
497   m_iHasGainInfo |= REPLAY_GAIN_HAS_TRACK_PEAK;
498 }
499
500 void CMusicInfoTag::SetReplayGainAlbumPeak(float albumPeak)
501 {
502   m_fAlbumPeak = albumPeak;
503   m_iHasGainInfo |= REPLAY_GAIN_HAS_ALBUM_PEAK;
504 }
505
506 void CMusicInfoTag::SetArtist(const CArtist& artist)
507 {
508   SetArtist(artist.strArtist);
509   SetAlbumArtist(artist.strArtist);
510   SetGenre(artist.genre);
511   m_iDbId = artist.idArtist;
512   m_type = "artist";
513   m_bLoaded = true;
514 }
515
516 void CMusicInfoTag::SetAlbum(const CAlbum& album)
517 {
518   SetArtist(album.artist);
519   SetAlbumId(album.idAlbum);
520   SetAlbum(album.strAlbum);
521   SetTitle(album.strAlbum);
522   SetAlbumArtist(album.artist);
523   SetGenre(album.genre);
524   SetRating('0' + album.iRating);
525   SetCompilation(album.bCompilation);
526   SYSTEMTIME stTime;
527   stTime.wYear = album.iYear;
528   SetReleaseDate(stTime);
529   m_iTimesPlayed = album.iTimesPlayed;
530   m_iDbId = album.idAlbum;
531   m_type = "album";
532   m_bLoaded = true;
533 }
534
535 void CMusicInfoTag::SetSong(const CSong& song)
536 {
537   SetTitle(song.strTitle);
538   SetGenre(song.genre);
539   SetArtist(song.artist);
540   SetAlbum(song.strAlbum);
541   SetAlbumArtist(song.albumArtist);
542   SetMusicBrainzTrackID(song.strMusicBrainzTrackID);
543   SetComment(song.strComment);
544   SetPlayCount(song.iTimesPlayed);
545   SetLastPlayed(song.lastPlayed);
546   m_rating = song.rating;
547   m_strURL = song.strFileName;
548   SYSTEMTIME stTime;
549   stTime.wYear = song.iYear;
550   SetReleaseDate(stTime);
551   m_iTrack = song.iTrack;
552   m_iDuration = song.iDuration;
553   m_iDbId = song.idSong;
554   m_type = "song";
555   m_bLoaded = true;
556   m_iTimesPlayed = song.iTimesPlayed;
557   m_iAlbumId = song.idAlbum;
558 }
559
560 void CMusicInfoTag::Serialize(CVariant& value) const
561 {
562   value["url"] = m_strURL;
563   value["title"] = m_strTitle;
564   if (m_type.compare("artist") == 0 && m_artist.size() == 1)
565     value["artist"] = m_artist[0];
566   else
567     value["artist"] = m_artist;
568   value["displayartist"] = StringUtils::Join(m_artist, g_advancedSettings.m_musicItemSeparator);
569   value["album"] = m_strAlbum;
570   value["albumartist"] = m_albumArtist;
571   value["genre"] = m_genre;
572   value["duration"] = m_iDuration;
573   value["track"] = GetTrackNumber();
574   value["disc"] = GetDiscNumber();
575   value["loaded"] = m_bLoaded;
576   value["year"] = m_dwReleaseDate.wYear;
577   value["musicbrainztrackid"] = m_strMusicBrainzTrackID;
578   value["musicbrainzartistid"] = StringUtils::Join(m_musicBrainzArtistID, " / ");
579   value["musicbrainzalbumid"] = m_strMusicBrainzAlbumID;
580   value["musicbrainzalbumartistid"] = StringUtils::Join(m_musicBrainzAlbumArtistID, " / ");
581   value["musicbrainztrmid"] = m_strMusicBrainzTRMID;
582   value["comment"] = m_strComment;
583   value["rating"] = (int)(m_rating - '0');
584   value["playcount"] = m_iTimesPlayed;
585   value["lastplayed"] = m_lastPlayed.IsValid() ? m_lastPlayed.GetAsDBDateTime() : StringUtils::EmptyString;
586   value["lyrics"] = m_strLyrics;
587   value["albumid"] = m_iAlbumId;
588   value["compilationartist"] = m_bCompilation;
589 }
590
591 void CMusicInfoTag::ToSortable(SortItem& sortable, Field field) const
592 {
593   switch (field)
594   {
595   case FieldTitle:       sortable[FieldTitle] = m_strTitle; break;
596   case FieldArtist:      sortable[FieldArtist] = m_artist; break;
597   case FieldAlbum:       sortable[FieldAlbum] = m_strAlbum; break;
598   case FieldAlbumArtist: sortable[FieldAlbumArtist] = m_albumArtist; break;
599   case FieldGenre:       sortable[FieldGenre] = m_genre; break;
600   case FieldTime:        sortable[FieldTime] = m_iDuration; break;
601   case FieldTrackNumber: sortable[FieldTrackNumber] = m_iTrack; break;
602   case FieldYear:        sortable[FieldYear] = m_dwReleaseDate.wYear; break;
603   case FieldComment:     sortable[FieldComment] = m_strComment; break;
604   case FieldRating:      sortable[FieldRating] = (float)(m_rating - '0'); break;
605   case FieldPlaycount:   sortable[FieldPlaycount] = m_iTimesPlayed; break;
606   case FieldLastPlayed:  sortable[FieldLastPlayed] = m_lastPlayed.IsValid() ? m_lastPlayed.GetAsDBDateTime() : StringUtils::EmptyString; break;
607   case FieldListeners:   sortable[FieldListeners] = m_listeners; break;
608   case FieldId:          sortable[FieldId] = (int64_t)m_iDbId; break;
609   default: break;
610   }
611 }
612
613 void CMusicInfoTag::Archive(CArchive& ar)
614 {
615   if (ar.IsStoring())
616   {
617     ar << m_strURL;
618     ar << m_strTitle;
619     ar << m_artist;
620     ar << m_strAlbum;
621     ar << m_albumArtist;
622     ar << m_genre;
623     ar << m_iDuration;
624     ar << m_iTrack;
625     ar << m_bLoaded;
626     ar << m_dwReleaseDate;
627     ar << m_strMusicBrainzTrackID;
628     ar << m_musicBrainzArtistID;
629     ar << m_strMusicBrainzAlbumID;
630     ar << m_musicBrainzAlbumArtistID;
631     ar << m_strMusicBrainzTRMID;
632     ar << m_lastPlayed;
633     ar << m_strComment;
634     ar << m_rating;
635     ar << m_iTimesPlayed;
636     ar << m_iAlbumId;
637     ar << m_iDbId;
638     ar << m_type;
639     ar << m_strLyrics;
640     ar << m_bCompilation;
641     ar << m_listeners;
642   }
643   else
644   {
645     ar >> m_strURL;
646     ar >> m_strTitle;
647     ar >> m_artist;
648     ar >> m_strAlbum;
649     ar >> m_albumArtist;
650     ar >> m_genre;
651     ar >> m_iDuration;
652     ar >> m_iTrack;
653     ar >> m_bLoaded;
654     ar >> m_dwReleaseDate;
655     ar >> m_strMusicBrainzTrackID;
656     ar >> m_musicBrainzArtistID;
657     ar >> m_strMusicBrainzAlbumID;
658     ar >> m_musicBrainzAlbumArtistID;
659     ar >> m_strMusicBrainzTRMID;
660     ar >> m_lastPlayed;
661     ar >> m_strComment;
662     ar >> m_rating;
663     ar >> m_iTimesPlayed;
664     ar >> m_iAlbumId;
665     ar >> m_iDbId;
666     ar >> m_type;
667     ar >> m_strLyrics;
668     ar >> m_bCompilation;
669     ar >> m_listeners;
670   }
671 }
672
673 void CMusicInfoTag::Clear()
674 {
675   m_strURL.clear();
676   m_artist.clear();
677   m_strAlbum.clear();
678   m_albumArtist.clear();
679   m_genre.clear();
680   m_strTitle.clear();
681   m_strMusicBrainzTrackID.clear();
682   m_musicBrainzArtistID.clear();
683   m_strMusicBrainzAlbumID.clear();
684   m_musicBrainzAlbumArtistID.clear();
685   m_strMusicBrainzTRMID.clear();
686   m_iDuration = 0;
687   m_iTrack = 0;
688   m_bLoaded = false;
689   m_lastPlayed.Reset();
690   m_bCompilation = false;
691   m_strComment.clear();
692   m_rating = '0';
693   m_iDbId = -1;
694   m_type.clear();
695   m_iTimesPlayed = 0;
696   memset(&m_dwReleaseDate, 0, sizeof(m_dwReleaseDate) );
697   m_iAlbumId = -1;
698   m_coverArt.clear();
699   m_iTrackGain = 0;
700   m_iAlbumGain = 0;
701   m_fTrackPeak = 0.0f;
702   m_fAlbumPeak = 0.0f;
703   m_iHasGainInfo = 0;
704 }
705
706 void CMusicInfoTag::AppendArtist(const CStdString &artist)
707 {
708   for (unsigned int index = 0; index < m_artist.size(); index++)
709   {
710     if (artist.Equals(m_artist.at(index).c_str()))
711       return;
712   }
713
714   m_artist.push_back(artist);
715 }
716
717 void CMusicInfoTag::AppendAlbumArtist(const CStdString &albumArtist)
718 {
719   for (unsigned int index = 0; index < m_albumArtist.size(); index++)
720   {
721     if (albumArtist.Equals(m_albumArtist.at(index).c_str()))
722       return;
723   }
724
725   m_albumArtist.push_back(albumArtist);
726 }
727
728 void CMusicInfoTag::AppendGenre(const CStdString &genre)
729 {
730   for (unsigned int index = 0; index < m_genre.size(); index++)
731   {
732     if (genre.Equals(m_genre.at(index).c_str()))
733       return;
734   }
735
736   m_genre.push_back(genre);
737 }
738
739 CStdString CMusicInfoTag::Trim(const CStdString &value) const
740 {
741   CStdString trimmedValue(value);
742   trimmedValue.TrimLeft(' ');
743   trimmedValue.TrimRight(" \n\r");
744   return trimmedValue;
745 }