Tag Parser  6.4.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
tagtarget.cpp
Go to the documentation of this file.
1 #include "./tagtarget.h"
2 
4 
5 #include <c++utilities/conversion/stringconversion.h>
6 
7 #include <list>
8 
9 using namespace std;
10 using namespace ConversionUtilities;
11 
12 namespace Media {
13 
17 const char *tagTargetLevelName(TagTargetLevel tagTargetLevel)
18 {
19  switch(tagTargetLevel) {
20  case TagTargetLevel::Shot:
21  return "shot";
22  case TagTargetLevel::Subtrack:
23  return "subtrack, part, movement, scene";
25  return "track, song, chapter";
26  case TagTargetLevel::Part:
27  return "part, session";
29  return "album, opera, concert, movie, episode";
30  case TagTargetLevel::Edition:
31  return "edition, issue, volume, opus, season, sequel";
32  case TagTargetLevel::Collection:
33  return "collection";
34  default:
35  return "";
36  }
37 }
38 
60 string TagTarget::toString(TagTargetLevel tagTargetLevel) const
61 {
62  string levelString;
63  if(level()) {
64  levelString += "level ";
65  levelString += numberToString(level());
66  }
67  const char *defaultLevelName;
68  if(!levelName().empty() || *(defaultLevelName = tagTargetLevelName(tagTargetLevel))) {
69  if(!levelString.empty()) {
70  levelString += ' ';
71  }
72  levelString += '\'';
73  if(!levelName().empty()) {
74  levelString += levelName();
75  } else {
76  levelString += defaultLevelName;
77  }
78  levelString += '\'';
79  }
80  list<string> parts;
81  if(levelString.empty()) {
82  parts.emplace_back("undefined target");
83  } else {
84  parts.emplace_back(move(levelString));
85  }
86  for(auto v : tracks()) {
87  parts.emplace_back("track " + numberToString(v));
88  }
89  for(auto v : chapters()) {
90  parts.emplace_back("chapter " + numberToString(v));
91  }
92  for(auto v : editions()) {
93  parts.emplace_back("edition " + numberToString(v));
94  }
95  for(auto v : attachments()) {
96  parts.emplace_back("attachment " + numberToString(v));
97  }
98  return joinStrings(parts, ", ");
99 }
100 
101 }
TAG_PARSER_EXPORT const char * tagTargetLevelName(TagTargetLevel tagTargetLevel)
Returns a string representation for the specified tagTargetLevel.
Definition: tagtarget.cpp:17
STL namespace.
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition: tagtarget.h:17
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9