Tag Parser  9.4.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
abstractchapter.cpp
Go to the documentation of this file.
1 #include "./abstractchapter.h"
2 
3 #include <sstream>
4 
5 using namespace std;
6 using namespace CppUtilities;
7 
8 namespace TagParser {
9 
18 AbstractChapter::AbstractChapter()
19  : m_id(0)
20  , m_startTime(-1)
21  , m_endTime(-1)
22  , m_hidden(false)
23  , m_enabled(true)
24 {
25 }
26 
31 {
32 }
33 
37 string AbstractChapter::label() const
38 {
39  stringstream ss;
40  ss << "ID: " << id();
41  if (!names().empty()) {
42  ss << ", name: \"" << names().front() << "\"";
43  }
44  if (!startTime().isNegative()) {
45  ss << ", start: " << startTime().toString(TimeSpanOutputFormat::WithMeasures);
46  }
47  return ss.str();
48 }
49 
54 {
55  m_id = 0;
56  m_names.clear();
57  m_startTime = m_endTime = TimeSpan(-1);
58  m_tracks.clear();
59  m_hidden = false;
60  m_enabled = true;
61 }
62 
71 {
72  clear();
73  internalParse(diag);
74 }
75 
82 {
83  clear();
84  internalParse(diag);
85  for (size_t i = 0, count = nestedChapterCount(); i < count; ++i) {
86  nestedChapter(i)->parseNested(diag);
87  }
88 }
89 
100 } // namespace TagParser
TagParser::AbstractChapter::nestedChapterCount
virtual std::size_t nestedChapterCount() const
Returns the number of nested chapters.
Definition: abstractchapter.h:122
TagParser::AbstractChapter::clear
virtual void clear()
Resets the object to its initial state.
Definition: abstractchapter.cpp:53
TagParser::AbstractChapter::m_enabled
bool m_enabled
Definition: abstractchapter.h:44
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::AbstractChapter::m_startTime
CppUtilities::TimeSpan m_startTime
Definition: abstractchapter.h:40
TagParser::AbstractChapter::m_names
std::vector< LocaleAwareString > m_names
Definition: abstractchapter.h:39
TagParser::AbstractChapter::parseNested
void parseNested(Diagnostics &diag)
Parses the chapter and nested chapters recursively.
Definition: abstractchapter.cpp:81
TagParser::AbstractChapter::m_tracks
std::vector< std::uint64_t > m_tracks
Definition: abstractchapter.h:42
abstractchapter.h
TagParser::AbstractChapter::~AbstractChapter
virtual ~AbstractChapter()
Destroys the chapter.
Definition: abstractchapter.cpp:30
TagParser::AbstractChapter::id
std::uint64_t id() const
Returns the chapter ID if known; otherwise returns zero.
Definition: abstractchapter.h:50
CppUtilities
Definition: abstractcontainer.h:15
TagParser::AbstractChapter::m_endTime
CppUtilities::TimeSpan m_endTime
Definition: abstractchapter.h:41
TagParser::AbstractChapter::names
const std::vector< LocaleAwareString > & names() const
Returns the chapter name.
Definition: abstractchapter.h:58
TagParser::AbstractChapter::m_id
std::uint64_t m_id
Definition: abstractchapter.h:38
TagParser::AbstractChapter::nestedChapter
virtual AbstractChapter * nestedChapter(std::size_t index)
Returns the nested chapter with the specified index.
Definition: abstractchapter.h:106
TagParser::AbstractChapter::label
std::string label() const
Returns a label for the chapter.
Definition: abstractchapter.cpp:37
TagParser::AbstractChapter::internalParse
virtual void internalParse(Diagnostics &diag)=0
Internally called to parse the chapter.
TagParser::AbstractChapter::parse
void parse(Diagnostics &diag)
Parses the chapter.
Definition: abstractchapter.cpp:70
TagParser::AbstractChapter::startTime
CppUtilities::TimeSpan startTime() const
Returns the start time if known; otherwise returns a negative time span.
Definition: abstractchapter.h:66
TagParser::AbstractChapter::m_hidden
bool m_hidden
Definition: abstractchapter.h:43