-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathabstractchapter.cpp
105 lines (92 loc) · 2.24 KB
/
abstractchapter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "./abstractchapter.h"
#include "./progressfeedback.h"
#include <sstream>
using namespace std;
using namespace CppUtilities;
namespace TagParser {
/// \brief The AbstractChapterPrivate struct contains private fields of the AbstractChapter class.
struct AbstractChapterPrivate {};
/*!
* \class TagParser::AbstractChapter
* \brief The AbstractChapter class parses chapter information.
*/
/*!
* \brief Constructs a new chapter.
*/
AbstractChapter::AbstractChapter()
: m_id(0)
, m_startTime(-1)
, m_endTime(-1)
, m_hidden(false)
, m_enabled(true)
{
}
/*!
* \brief Destroys the chapter.
*/
AbstractChapter::~AbstractChapter()
{
}
/*!
* \brief Returns a label for the chapter.
*/
string AbstractChapter::label() const
{
stringstream ss;
ss << "ID: " << id();
if (!names().empty()) {
ss << ", name: \"" << names().front() << "\"";
}
if (!startTime().isNegative()) {
ss << ", start: " << startTime().toString(TimeSpanOutputFormat::WithMeasures);
}
return ss.str();
}
/*!
* \brief Resets the object to its initial state.
*/
void AbstractChapter::clear()
{
m_id = 0;
m_names.clear();
m_startTime = m_endTime = TimeSpan(-1);
m_tracks.clear();
m_hidden = false;
m_enabled = true;
}
/*!
* \brief Parses the chapter.
*
* Fetches nested chapters but does not parse them.
*
* Clears all previous parsing results.
*/
void AbstractChapter::parse(Diagnostics &diag, AbortableProgressFeedback &progress)
{
clear();
internalParse(diag, progress);
}
/*!
* \brief Parses the chapter and nested chapters recursively.
*
* Clears all previous parsing results.
*/
void AbstractChapter::parseNested(Diagnostics &diag, AbortableProgressFeedback &progress)
{
progress.stopIfAborted();
clear();
internalParse(diag, progress);
for (size_t i = 0, count = nestedChapterCount(); i < count; ++i) {
nestedChapter(i)->parseNested(diag, progress);
}
}
/*!
* \fn AbstractChapter::internalParse()
* \brief Internally called to parse the chapter.
*
* Must be implemented when subclassing.
*
* \throws Throws Failure or a derived class when a parsing error occurs.
* \throws Throws std::ios_base::failure when an IO error occurs.
*/
} // namespace TagParser