Tag Parser: tagtarget.cpp Source File

Tag Parser 12.5.3 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
3#include "./matroska/matroskatagid.h"
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) {
20 case TagTargetLevel::Shot:
21 return "shot";
22 case TagTargetLevel::Subtrack:
23 return "subtrack, part, movement, scene";
24 case TagTargetLevel::Track:
25 return "track, song, chapter";
26 case TagTargetLevel::Part:
27 return "part, session";
28 case TagTargetLevel::Album:
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 std::string_view();
36 }
37}
38
55
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
TagParser::TagTarget::tracks
const IdContainerType & tracks() const
Returns the tracks.
Definition tagtarget.h:105
TagParser::TagTarget::chapters
const IdContainerType & chapters() const
Returns the chapters.
Definition tagtarget.h:121
TagParser::TagTarget::level
std::uint64_t level() const
Returns the level.
Definition tagtarget.h:73
TagParser::TagTarget::toString
std::string toString(const std::function< TagTargetLevel(std::uint64_t)> &tagTargetMapping) const
Returns the string representation of the current instance.
Definition tagtarget.h:217
TagParser::TagTarget::levelName
const std::string & levelName() const
Returns the level name.
Definition tagtarget.h:89
TagParser::TagTarget::editions
const IdContainerType & editions() const
Returns the editions.
Definition tagtarget.h:137
TagParser::TagTarget::attachments
const IdContainerType & attachments() const
Returns the attachments.
Definition tagtarget.h:153
matroskatagid.h
CppUtilities
Definition abstractcontainer.h:16
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::tagTargetLevelName
TAG_PARSER_EXPORT std::string_view tagTargetLevelName(TagTargetLevel tagTargetLevel)
Returns a string representation for the specified tagTargetLevel.
Definition tagtarget.cpp:17
TagParser::TagTargetLevel
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition tagtarget.h:16
TagParser::TagTargetLevel::Edition
@ Edition
Definition tagtarget.h:16
TagParser::TagTargetLevel::Shot
@ Shot
Definition tagtarget.h:16
TagParser::TagTargetLevel::Part
@ Part
Definition tagtarget.h:16
TagParser::TagTargetLevel::Subtrack
@ Subtrack
Definition tagtarget.h:16
TagParser::TagTargetLevel::Track
@ Track
Definition tagtarget.h:16
TagParser::TagTargetLevel::Album
@ Album
Definition tagtarget.h:16
TagParser::TagTargetLevel::Collection
@ Collection
Definition tagtarget.h:16
tagtarget.h