Tag Parser  6.4.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 Media {
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 
30 {}
31 
35 string AbstractChapter::label() const
36 {
37  stringstream ss;
38  ss << "ID: " << id();
39  if(!names().empty()) {
40  ss << ", name: \"" << names().front() << "\"";
41  }
42  if(!startTime().isNegative()) {
43  ss << ", start: " << startTime().toString(TimeSpanOutputFormat::WithMeasures);
44  }
45  return ss.str();
46 }
47 
52 {
53  m_id = 0;
54  m_names.clear();
56  m_tracks.clear();
57  m_hidden = false;
58  m_enabled = true;
59 }
60 
69 {
70  clear();
72  internalParse();
73 }
74 
81 {
82  clear();
84  internalParse();
85  for(size_t i = 0, count = nestedChapterCount(); i < count; ++i) {
87  }
88 }
89 
100 } // namespace Media
101 
void invalidateStatus()
Invalidates the current status.
std::string label() const
Returns a label for the chapter.
std::vector< uint64 > m_tracks
ChronoUtilities::TimeSpan m_startTime
virtual ~AbstractChapter()
Destroys the chapter.
STL namespace.
void parse()
Parses the chapter.
void parseNested()
Parses the chapter and nested chapters recursively.
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.
ChronoUtilities::TimeSpan m_endTime
uint64 id() const
Returns the chapter ID if known; otherwise returns zero.
virtual void clear()
Resets the object to its initial state.
virtual AbstractChapter * nestedChapter(std::size_t index)
Returns the nested chapter with the specified index.
std::vector< LocaleAwareString > m_names
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
virtual void internalParse()=0
Internally called to parse the chapter.
virtual std::size_t nestedChapterCount() const
Returns the number of nested chapters.