Tag Parser 12.4.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
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
9using namespace std;
10using namespace CppUtilities;
11
12namespace TagParser {
13
17std::string_view tagTargetLevelName(TagTargetLevel tagTargetLevel)
18{
19 switch (tagTargetLevel) {
21 return "shot";
23 return "subtrack, part, movement, scene";
25 return "track, song, chapter";
27 return "part, session";
29 return "album, opera, concert, movie, episode";
31 return "edition, issue, volume, opus, season, sequel";
33 return "collection";
34 default:
35 return std::string_view();
36 }
37}
38
60std::string TagTarget::toString(TagTargetLevel tagTargetLevel) const
61{
62 auto levelString = std::string();
63 if (level()) {
64 levelString += "level ";
65 levelString += numberToString(level());
66 }
67 auto defaultLevelName = std::string_view();
68 if (!levelName().empty() || !(defaultLevelName = tagTargetLevelName(tagTargetLevel)).empty()) {
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(std::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} // namespace TagParser
const IdContainerType & tracks() const
Returns the tracks.
Definition tagtarget.h:105
const IdContainerType & chapters() const
Returns the chapters.
Definition tagtarget.h:121
std::uint64_t level() const
Returns the level.
Definition tagtarget.h:73
std::string toString(const std::function< TagTargetLevel(std::uint64_t)> &tagTargetMapping) const
Returns the string representation of the current instance.
Definition tagtarget.h:217
const std::string & levelName() const
Returns the level name.
Definition tagtarget.h:89
const IdContainerType & editions() const
Returns the editions.
Definition tagtarget.h:137
const IdContainerType & attachments() const
Returns the attachments.
Definition tagtarget.h:153
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TAG_PARSER_EXPORT std::string_view tagTargetLevelName(TagTargetLevel tagTargetLevel)
Returns a string representation for the specified tagTargetLevel.
Definition tagtarget.cpp:17
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition tagtarget.h:16