Tag Parser: abstractchapter.cpp Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
abstractchapter.cpp
Go to the documentation of this file.
1#include "./abstractchapter.h"
2#include "./progressfeedback.h"
3
4#include <sstream>
5
6using namespace std;
7using namespace CppUtilities;
8
9namespace TagParser {
10
12 struct AbstractChapterPrivate {};
13
18
22AbstractChapter::AbstractChapter()
23 : m_id(0)
24 , m_startTime(-1)
25 , m_endTime(-1)
26 , m_hidden(false)
27 , m_enabled(true)
28{
29}
30
34AbstractChapter::~AbstractChapter()
35{
36}
37
41 string AbstractChapter::label() const
42{
43 stringstream ss;
44 ss << "ID: " << id();
45 if (!names().empty()) {
46 ss << ", name: \"" << names().front() << "\"";
47 }
48 if (!startTime().isNegative()) {
49 ss << ", start: " << startTime().toString(TimeSpanOutputFormat::WithMeasures);
50 }
51 return ss.str();
52}
53
57 void AbstractChapter::clear()
58{
59 m_id = 0;
60 m_names.clear();
61 m_startTime = m_endTime = TimeSpan(-1);
62 m_tracks.clear();
63 m_hidden = false;
64 m_enabled = true;
65}
66
74 void AbstractChapter::parse(Diagnostics &diag, AbortableProgressFeedback &progress)
75{
76 clear();
77 internalParse(diag, progress);
78}
79
85 void AbstractChapter::parseNested(Diagnostics &diag, AbortableProgressFeedback &progress)
86{
87 progress.stopIfAborted();
88 clear();
89 internalParse(diag, progress);
90 for (size_t i = 0, count = nestedChapterCount(); i < count; ++i) {
91 nestedChapter(i)->parseNested(diag, progress);
92 }
93}
94
104
105} // namespace TagParser
abstractchapter.h
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:186
TagParser::AbortableProgressFeedback::stopIfAborted
void stopIfAborted() const
Throws an OperationAbortedException if aborted.
Definition progressfeedback.h:255
TagParser::AbstractChapter::m_enabled
bool m_enabled
Definition abstractchapter.h:48
TagParser::AbstractChapter::parseNested
void parseNested(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the chapter and nested chapters recursively.
Definition abstractchapter.cpp:85
TagParser::AbstractChapter::nestedChapterCount
virtual std::size_t nestedChapterCount() const
Returns the number of nested chapters.
Definition abstractchapter.h:126
TagParser::AbstractChapter::m_id
std::uint64_t m_id
Definition abstractchapter.h:41
TagParser::AbstractChapter::names
const std::vector< LocaleAwareString > & names() const
Returns the chapter name.
Definition abstractchapter.h:62
TagParser::AbstractChapter::m_tracks
std::vector< std::uint64_t > m_tracks
Definition abstractchapter.h:45
TagParser::AbstractChapter::internalParse
virtual void internalParse(Diagnostics &diag, AbortableProgressFeedback &progress)=0
Internally called to parse the chapter.
TagParser::AbstractChapter::m_endTime
CppUtilities::TimeSpan m_endTime
Definition abstractchapter.h:44
TagParser::AbstractChapter::m_hidden
bool m_hidden
Definition abstractchapter.h:47
TagParser::AbstractChapter::m_startTime
CppUtilities::TimeSpan m_startTime
Definition abstractchapter.h:43
TagParser::AbstractChapter::parse
void parse(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the chapter.
Definition abstractchapter.cpp:74
TagParser::AbstractChapter::clear
virtual void clear()
Resets the object to its initial state.
Definition abstractchapter.cpp:57
TagParser::AbstractChapter::label
std::string label() const
Returns a label for the chapter.
Definition abstractchapter.cpp:41
TagParser::AbstractChapter::startTime
CppUtilities::TimeSpan startTime() const
Returns the start time if known; otherwise returns a negative time span.
Definition abstractchapter.h:70
TagParser::AbstractChapter::nestedChapter
virtual AbstractChapter * nestedChapter(std::size_t index)
Returns the nested chapter with the specified index.
Definition abstractchapter.h:110
TagParser::AbstractChapter::id
std::uint64_t id() const
Returns the chapter ID if known; otherwise returns zero.
Definition abstractchapter.h:54
TagParser::AbstractChapter::AbstractChapter
AbstractChapter()
Constructs a new chapter.
Definition abstractchapter.cpp:22
TagParser::AbstractChapter::~AbstractChapter
virtual ~AbstractChapter()
Destroys the chapter.
Definition abstractchapter.cpp:34
TagParser::AbstractChapter::m_names
std::vector< LocaleAwareString > m_names
Definition abstractchapter.h:42
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
CppUtilities
Definition abstractcontainer.h:16
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::TagDataType::TimeSpan
@ TimeSpan
Definition tagvalue.h:124
progressfeedback.h
TagParser::AbstractChapterPrivate
The AbstractChapterPrivate struct contains private fields of the AbstractChapter class.
Definition abstractchapter.cpp:12