Tag Parser  8.0.1
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 ChronoUtilities;
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();
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
uint64 id() const
Returns the chapter ID if known; otherwise returns zero.
void parse(Diagnostics &diag)
Parses the chapter.
ChronoUtilities::TimeSpan m_startTime
std::vector< LocaleAwareString > m_names
STL namespace.
virtual void internalParse(Diagnostics &diag)=0
Internally called to parse the chapter.
const std::vector< LocaleAwareString > & names() const
Returns the chapter name.
ChronoUtilities::TimeSpan startTime() const
Returns the start time if known; otherwise returns a negative time span.
void parseNested(Diagnostics &diag)
Parses the chapter and nested chapters recursively.
ChronoUtilities::TimeSpan m_endTime
virtual std::size_t nestedChapterCount() const
Returns the number of nested chapters.
virtual void clear()
Resets the object to its initial state.
std::string label() const
Returns a label for the chapter.
std::vector< uint64 > m_tracks
virtual ~AbstractChapter()
Destroys the chapter.
virtual AbstractChapter * nestedChapter(std::size_t index)
Returns the nested chapter with the specified index.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156