Tag Parser: tests/utils.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
utils.cpp
Go to the documentation of this file.
1#include "./helper.h"
2
3#include "../aspectratio.h"
4#include "../backuphelper.h"
5#include "../diagnostics.h"
6#include "../exceptions.h"
7#include "../margin.h"
8#include "../mediafileinfo.h"
9#include "../mediaformat.h"
10#include "../positioninset.h"
11#include "../progressfeedback.h"
12#include "../signature.h"
13#include "../size.h"
14#include "../tagtarget.h"
15
16#include "../id3/id3v2tag.h"
17
18#include <c++utilities/conversion/stringbuilder.h>
19#include <c++utilities/tests/testutils.h>
20using namespace CppUtilities;
21
22#include <cppunit/TestFixture.h>
23#include <cppunit/extensions/HelperMacros.h>
24
25#include <cstdio>
26#include <filesystem>
27#include <regex>
28
29using namespace std;
30using namespace CppUtilities::Literals;
31using namespace TagParser;
32using namespace CPPUNIT_NS;
33
37 class UtilitiesTests : public TestFixture {
38 CPPUNIT_TEST_SUITE(UtilitiesTests);
39 CPPUNIT_TEST(testSize);
40 CPPUNIT_TEST(testTagTarget);
41 CPPUNIT_TEST(testSignature);
42 CPPUNIT_TEST(testMargin);
43 CPPUNIT_TEST(testAspectRatio);
44 CPPUNIT_TEST(testMediaFormat);
45 CPPUNIT_TEST(testPositionInSet);
46 CPPUNIT_TEST(testProgressFeedback);
47 CPPUNIT_TEST(testAbortableProgressFeedback);
48 CPPUNIT_TEST(testDiagnostics);
49 CPPUNIT_TEST(testBackupFile);
50 CPPUNIT_TEST(testFieldConversions);
51 CPPUNIT_TEST_SUITE_END();
52
53public:
54 void setUp() override;
55 void tearDown() override;
56
57 void testSize();
58 void testStatusProvider();
59 void testTagTarget();
60 void testSignature();
61 void testMargin();
62 void testAspectRatio();
63 void testMediaFormat();
64 void testPositionInSet();
65 void testProgressFeedback();
66 void testAbortableProgressFeedback();
67 void testDiagnostics();
68 void testBackupFile();
69 void testFieldConversions();
70};
71
72CPPUNIT_TEST_SUITE_REGISTRATION(UtilitiesTests);
73
74 void UtilitiesTests::setUp()
75{
76}
77
78 void UtilitiesTests::tearDown()
79{
80}
81
82 void UtilitiesTests::testSize()
83{
84 static_assert(Size().isNull(), "Size::isNull()");
85 static_assert(!Size(3, 4).isNull(), "Size::isNull()");
86 static_assert(Size(3, 4).resolution() == 12, "Size::resolution");
87
88 Size size(1920, 1080);
89 CPPUNIT_ASSERT_EQUAL("width: 1920, height: 1080"s, size.toString());
90 CPPUNIT_ASSERT_EQUAL("1080p"s, string(size.abbreviation()));
91 size.setWidth(1280);
92 size.setHeight(720);
93 CPPUNIT_ASSERT_EQUAL("720p"s, string(size.abbreviation()));
94}
95
96 void UtilitiesTests::testTagTarget()
97{
98 TagTarget target;
99 CPPUNIT_ASSERT(target.isEmpty());
100 CPPUNIT_ASSERT_EQUAL_MESSAGE("default level is 50", static_cast<std::uint64_t>(50), target.level());
101 CPPUNIT_ASSERT_EQUAL("level 50"s, target.toString(TagTargetLevel::Unspecified));
102 target = TagTarget(30, { 1, 2, 3 }, { 4 }, { 5, 6 }, { 7, 8, 9 });
103 CPPUNIT_ASSERT(!target.isEmpty());
104 const auto mapping = [](std::uint64_t level) { return level == 30 ? TagTargetLevel::Track : TagTargetLevel::Unspecified; };
105 CPPUNIT_ASSERT_EQUAL(
106 "level 30 'track, song, chapter', track 1, track 2, track 3, chapter 4, edition 5, edition 6, attachment 7, attachment 8, attachment 9"s,
107 target.toString(mapping));
108 target.setLevel(40);
109 CPPUNIT_ASSERT_EQUAL("level 40, track 1, track 2, track 3, chapter 4, edition 5, edition 6, attachment 7, attachment 8, attachment 9"s,
110 target.toString(mapping));
111 target.setLevelName("test");
112 CPPUNIT_ASSERT_EQUAL("level 40 'test', track 1, track 2, track 3, chapter 4, edition 5, edition 6, attachment 7, attachment 8, attachment 9"s,
113 target.toString(mapping));
114 CPPUNIT_ASSERT(target == TagTarget(40, { 1, 2, 3 }, { 4 }, { 5, 6 }, { 7, 8, 9 }));
115 target.clear();
116 CPPUNIT_ASSERT(target.isEmpty());
117}
118
119 void UtilitiesTests::testSignature()
120{
121 const unsigned char xzHead[12] = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, 0xe6, 0xd6, 0xb4, 0x46 };
122
123 // truncated buffer
124 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Unknown, parseSignature(reinterpret_cast<const char *>(xzHead), 3));
125 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Unknown, parseSignature(reinterpret_cast<const char *>(xzHead), 2));
126 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Unknown, parseSignature(reinterpret_cast<const char *>(xzHead), 0));
127
128 const auto containerFormat = parseSignature(reinterpret_cast<const char *>(xzHead), sizeof(xzHead));
129 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Xz, containerFormat);
130 CPPUNIT_ASSERT_EQUAL("xz compressed file"s, string(containerFormatName(containerFormat)));
131 CPPUNIT_ASSERT_EQUAL("xz"s, string(containerFormatAbbreviation(containerFormat)));
132 CPPUNIT_ASSERT_EQUAL(string(), string(containerFormatSubversion(containerFormat)));
133}
134
135 void UtilitiesTests::testMargin()
136{
137 static_assert(Margin().isNull(), "empty margin");
138 static_assert(!Margin(0, 2).isNull(), "non-empty margin");
139
140 CPPUNIT_ASSERT_EQUAL("top: 1; left: 2; bottom: 3; right: 4"s, Margin(1, 2, 3, 4).toString());
141}
142
143 void UtilitiesTests::testAspectRatio()
144{
145 static_assert(!AspectRatio().isValid(), "invalid aspect ratio");
146 static_assert(AspectRatio(16, 9).isValid(), "valid aspect ratio");
147 static_assert(AspectRatio(16, 9).isExtended(), "extended aspect ratio");
148
149 const AspectRatio ratio(4);
150 CPPUNIT_ASSERT_EQUAL(static_cast<std::uint16_t>(16), ratio.numerator);
151 CPPUNIT_ASSERT_EQUAL(static_cast<std::uint16_t>(11), ratio.denominator);
152 const AspectRatio ratio2(77);
153 CPPUNIT_ASSERT_EQUAL(static_cast<std::uint16_t>(0), ratio2.numerator);
154 CPPUNIT_ASSERT_EQUAL(static_cast<std::uint16_t>(0), ratio2.denominator);
155}
156
157 void UtilitiesTests::testMediaFormat()
158{
159 // unspecific format
160 MediaFormat aac(GeneralMediaFormat::Aac);
161 CPPUNIT_ASSERT_EQUAL("Advanced Audio Coding"s, string(aac.name()));
162 CPPUNIT_ASSERT_EQUAL("AAC"s, string(aac.abbreviation()));
163 CPPUNIT_ASSERT_EQUAL("AAC"s, string(aac.shortAbbreviation()));
164
165 // specific format
166 aac += MediaFormat(GeneralMediaFormat::Aac, SubFormats::AacMpeg4LowComplexityProfile, ExtensionFormats::SpectralBandReplication);
167 CPPUNIT_ASSERT(aac == GeneralMediaFormat::Aac);
168 CPPUNIT_ASSERT(aac != GeneralMediaFormat::Mpeg1Audio);
169 CPPUNIT_ASSERT_EQUAL("Advanced Audio Coding Low Complexity Profile"s, string(aac.name()));
170 CPPUNIT_ASSERT_EQUAL("MPEG-4 AAC-LC"s, string(aac.abbreviation()));
171 CPPUNIT_ASSERT_EQUAL("HE-AAC"s, string(aac.shortAbbreviation()));
172 CPPUNIT_ASSERT_EQUAL("Spectral Band Replication / HE-AAC"s, string(aac.extensionName()));
173}
174
175 void UtilitiesTests::testPositionInSet()
176{
177 const PositionInSet empty;
178 CPPUNIT_ASSERT(empty.isNull());
179 CPPUNIT_ASSERT_EQUAL(0, empty.position());
180 CPPUNIT_ASSERT_EQUAL(0, empty.total());
181 CPPUNIT_ASSERT_EQUAL(""s, empty.toString());
182
183 const PositionInSet oneOfThree(1, 3);
184 CPPUNIT_ASSERT(!oneOfThree.isNull());
185 CPPUNIT_ASSERT_EQUAL(1, oneOfThree.position());
186 CPPUNIT_ASSERT_EQUAL(3, oneOfThree.total());
187 CPPUNIT_ASSERT_EQUAL("1/3"s, oneOfThree.toString());
188
189 const PositionInSet posOnly(5, 0);
190 CPPUNIT_ASSERT(!posOnly.isNull());
191 CPPUNIT_ASSERT_EQUAL(5, posOnly.position());
192 CPPUNIT_ASSERT_EQUAL(0, posOnly.total());
193 CPPUNIT_ASSERT_EQUAL("5"s, posOnly.toString());
194
195 const PositionInSet totalOnly(0, 5);
196 CPPUNIT_ASSERT(!totalOnly.isNull());
197 CPPUNIT_ASSERT_EQUAL(0, totalOnly.position());
198 CPPUNIT_ASSERT_EQUAL(5, totalOnly.total());
199 CPPUNIT_ASSERT_EQUAL("/5"s, totalOnly.toString());
200}
201
202 void UtilitiesTests::testProgressFeedback()
203{
204 unsigned int steps = 0;
205 string step;
206 unsigned int stepPercentage;
207 unsigned int overallPercentage = 0;
208
209 ProgressFeedback progressFeedback(
210 [&](const ProgressFeedback &progress) {
211 ++steps;
212 step = progress.step();
213 stepPercentage = progress.stepPercentage();
214 overallPercentage = progress.overallPercentage();
215 },
216 [&](const ProgressFeedback &progress) {
217 stepPercentage = progress.stepPercentage();
218 overallPercentage = progress.overallPercentage();
219 });
220 CPPUNIT_ASSERT_EQUAL(0u, steps);
221 progressFeedback.updateOverallPercentage(25);
222 CPPUNIT_ASSERT_EQUAL(0u, steps);
223 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
224 progressFeedback.updateStep("foo", 45);
225 CPPUNIT_ASSERT_EQUAL(1u, steps);
226 CPPUNIT_ASSERT_EQUAL("foo"s, step);
227 CPPUNIT_ASSERT_EQUAL(45u, stepPercentage);
228 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
229 progressFeedback.updateStepPercentage(60);
230 CPPUNIT_ASSERT_EQUAL(1u, steps);
231 CPPUNIT_ASSERT_EQUAL("foo"s, step);
232 CPPUNIT_ASSERT_EQUAL(60u, stepPercentage);
233 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
234 progressFeedback.updateStepPercentageFromFraction(0.75);
235 CPPUNIT_ASSERT_EQUAL(1u, steps);
236 CPPUNIT_ASSERT_EQUAL("foo"s, step);
237 CPPUNIT_ASSERT_EQUAL(75u, stepPercentage);
238 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
239}
240
241 void UtilitiesTests::testAbortableProgressFeedback()
242{
243 unsigned int steps = 0;
244 string step;
245 unsigned int stepPercentage;
246 unsigned int overallPercentage = 0;
247
248 AbortableProgressFeedback progressFeedback(
249 [&](const AbortableProgressFeedback &progress) {
250 ++steps;
251 step = progress.step();
252 stepPercentage = progress.stepPercentage();
253 overallPercentage = progress.overallPercentage();
254 },
255 [&](const AbortableProgressFeedback &progress) {
256 stepPercentage = progress.stepPercentage();
257 overallPercentage = progress.overallPercentage();
258 });
259 CPPUNIT_ASSERT(!progressFeedback.isAborted());
260 CPPUNIT_ASSERT_NO_THROW_MESSAGE("stop does nothing if not aborted", progressFeedback.stopIfAborted());
261 CPPUNIT_ASSERT_EQUAL(0u, steps);
262 progressFeedback.updateOverallPercentage(25);
263 CPPUNIT_ASSERT_EQUAL(0u, steps);
264 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
265 progressFeedback.updateStep("foo", 45);
266 CPPUNIT_ASSERT_EQUAL(1u, steps);
267 CPPUNIT_ASSERT_EQUAL("foo"s, step);
268 CPPUNIT_ASSERT_EQUAL(45u, stepPercentage);
269 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
270 CPPUNIT_ASSERT_NO_THROW_MESSAGE("next step continues if not aborted", progressFeedback.nextStepOrStop("bar", 33));
271 CPPUNIT_ASSERT_EQUAL(2u, steps);
272 CPPUNIT_ASSERT_EQUAL("bar"s, step);
273 CPPUNIT_ASSERT_EQUAL(33u, stepPercentage);
274 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
275 progressFeedback.tryToAbort();
276 CPPUNIT_ASSERT(progressFeedback.isAborted());
277 CPPUNIT_ASSERT_THROW(progressFeedback.nextStepOrStop("not going to happen", 33), OperationAbortedException);
278 CPPUNIT_ASSERT_EQUAL(2u, steps);
279 CPPUNIT_ASSERT_EQUAL("bar"s, step);
280 CPPUNIT_ASSERT_EQUAL(33u, stepPercentage);
281 CPPUNIT_ASSERT_EQUAL(25u, overallPercentage);
282}
283
284 void UtilitiesTests::testDiagnostics()
285{
286 Diagnostics diag;
287 CPPUNIT_ASSERT_EQUAL(DiagLevel::None, diag.level());
288 diag.emplace_back(DiagLevel::Warning, "warning msg", "context");
289 CPPUNIT_ASSERT_EQUAL(DiagLevel::Warning, diag.level());
290 CPPUNIT_ASSERT(!diag.has(DiagLevel::Critical));
291 diag.emplace_back(DiagLevel::Critical, "critical msg", "context");
292 CPPUNIT_ASSERT_EQUAL(DiagLevel::Critical, diag.level());
293 CPPUNIT_ASSERT(diag.has(DiagLevel::Critical));
294}
295
296 void UtilitiesTests::testBackupFile()
297{
298 using namespace BackupHelper;
299
300 // setup testfile
301 MediaFileInfo file(workingCopyPath("unsupported.bin"));
302 file.setBackupDirectory(string()); // ensure backup directory is empty, so backups will be created in the same directory as the original file
303 const auto workingDir(file.containingDirectory());
304 file.open();
305
306 // create backup file
307 string backupPath1, backupPath2;
308 NativeFileStream backupStream1, backupStream2;
309 createBackupFile(string(), file.path(), backupPath1, file.stream(), backupStream1);
310 CPPUNIT_ASSERT_EQUAL(workingDir + "/unsupported.bin.bak", backupPath1);
311
312 // recreate original file (like the 'make' methods would do to apply changes)
313 file.stream().open(file.path(), ios_base::out);
314 file.stream() << "test1" << endl;
315
316 // create a 2nd backup which should not override the first one
317 createBackupFile(string(), file.path(), backupPath2, file.stream(), backupStream2);
318 CPPUNIT_ASSERT_EQUAL(workingDir + "/unsupported.bin.1.bak", backupPath2);
319
320 // get rid of 2nd backup, recreate original file
321 backupStream2.close();
322 remove(backupPath2.data());
323 file.stream().open(file.path(), ios_base::out);
324 file.stream() << "test2" << endl;
325
326 // create backup under another location
327 try {
328 createBackupFile("bak", file.path(), backupPath2, file.stream(), backupStream2);
329 CPPUNIT_FAIL("renaming failed because backup dir does not exist");
330 } catch (const std::ios_base::failure &failure) {
331 TESTUTILS_ASSERT_LIKE("renaming error", "Unable to create backup file .* of .* before rewriting it: .*"s, string(failure.what()));
332 }
333 backupStream2.clear();
334 workingCopyPath("bak/unsupported.bin", WorkingCopyMode::NoCopy);
335 createBackupFile("bak", file.path(), backupPath2, file.stream(), backupStream2);
336 CPPUNIT_ASSERT_EQUAL(workingDir + "/bak/unsupported.bin", backupPath2);
337
338 // get rid of 2nd backup (again)
339 backupStream2.close();
340 CPPUNIT_ASSERT_EQUAL_MESSAGE("remove " + backupPath2, 0, remove(backupPath2.data()));
341 std::filesystem::remove_all(workingDir + "/bak");
342
343 // should be able to use backup stream, eg. seek to the end
344 backupStream1.seekg(0, ios_base::end);
345 CPPUNIT_ASSERT_EQUAL(41_st, static_cast<size_t>(backupStream1.tellg()));
346
347 // restore backup
348 restoreOriginalFileFromBackupFile(file.path(), backupPath1, file.stream(), backupStream1);
349
350 // check restored backup
351 file.open(true);
352 file.stream().seekg(0x1D);
353 CPPUNIT_ASSERT_EQUAL(0x34_st, static_cast<size_t>(file.stream().get()));
354 file.close();
355
356 // restore after user aborted
357 createBackupFile(string(), file.path(), backupPath1, file.stream(), backupStream1);
358 try {
359 throw OperationAbortedException();
360 } catch (...) {
361 Diagnostics diag;
362 CPPUNIT_ASSERT_THROW(
363 handleFailureAfterFileModified(file, backupPath1, file.stream(), backupStream1, diag, "test"), OperationAbortedException);
364 CPPUNIT_ASSERT(diag.level() < DiagLevel::Critical);
365 CPPUNIT_ASSERT(!diag.empty());
366 CPPUNIT_ASSERT_EQUAL("Rewriting the file to apply changed tag information has been aborted."s, diag.front().message());
367 CPPUNIT_ASSERT_EQUAL("The original file has been restored."s, diag.back().message());
368 }
369
370 // restore after error
371 createBackupFile(string(), file.path(), backupPath1, file.stream(), backupStream1);
372 try {
373 throw Failure();
374 } catch (...) {
375 Diagnostics diag;
376 CPPUNIT_ASSERT_THROW(handleFailureAfterFileModified(file, backupPath1, file.stream(), backupStream1, diag, "test"), Failure);
377 CPPUNIT_ASSERT(diag.level() >= DiagLevel::Critical);
378 CPPUNIT_ASSERT_EQUAL("Rewriting the file to apply changed tag information failed."s, diag.front().message());
379 CPPUNIT_ASSERT_EQUAL("The original file has been restored."s, diag.back().message());
380 }
381
382 // restore after io failure
383 createBackupFile(string(), file.path(), backupPath1, file.stream(), backupStream1);
384 try {
385 throw std::ios_base::failure("simulated IO failure");
386 } catch (const std::ios_base::failure &) {
387 Diagnostics diag;
388 CPPUNIT_ASSERT_THROW_MESSAGE("IO failure re-thrown",
389 handleFailureAfterFileModified(file, backupPath1, file.stream(), backupStream1, diag, "test"), std::ios_base::failure);
390 CPPUNIT_ASSERT(diag.level() >= DiagLevel::Critical);
391 CPPUNIT_ASSERT_EQUAL("An IO error occurred when rewriting the file to apply changed tag information."s, diag.front().message());
392 CPPUNIT_ASSERT_EQUAL("The original file has been restored."s, diag.back().message());
393 }
394
395 CPPUNIT_ASSERT_EQUAL(0, remove(file.path().data()));
396}
397
401 void UtilitiesTests::testFieldConversions()
402{
403 auto tag = Id3v2Tag();
404 tag.setVersion(4, 0);
405 for (auto knownField = firstKnownField; knownField != KnownField::Invalid; knownField = nextKnownField(knownField)) {
406 if (const auto fieldId = tag.fieldId(knownField)) {
407 CPPUNIT_ASSERT_EQUAL_MESSAGE("reverse mapping for known field exists", knownField, tag.knownField(fieldId));
408 }
409 }
410 tag.setVersion(2, 0);
411 for (auto knownField = firstKnownField; knownField != KnownField::Invalid; knownField = nextKnownField(knownField)) {
412 if (const auto fieldId = tag.fieldId(knownField)) {
413 CPPUNIT_ASSERT_EQUAL_MESSAGE("reverse mapping for known field exists", knownField, tag.knownField(fieldId));
414 }
415 }
416}
aspectratio.h
backuphelper.h
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:186
TagParser::BasicFileInfo::path
const std::string & path() const
Returns the path of the current file.
Definition basicfileinfo.h:103
TagParser::BasicFileInfo::containingDirectory
static std::string containingDirectory(std::string_view path)
Returns the path of the directory containing the given file.
Definition basicfileinfo.cpp:220
TagParser::BasicFileInfo::stream
CppUtilities::NativeFileStream & stream()
Returns the std::fstream for the current instance.
Definition basicfileinfo.h:85
TagParser::BasicFileInfo::open
void open(bool readOnly=false)
Opens a std::fstream for the current file.
Definition basicfileinfo.cpp:71
TagParser::BasicFileInfo::close
void close()
A possibly opened std::fstream will be closed.
Definition basicfileinfo.cpp:97
TagParser::BasicProgressFeedback::stepPercentage
std::uint8_t stepPercentage() const
Returns the percentage of the current step (initially 0, supposed to be a value from 0 to 100).
Definition progressfeedback.h:77
TagParser::BasicProgressFeedback::step
const std::string & step() const
Returns the name of the current step (initially empty).
Definition progressfeedback.h:68
TagParser::BasicProgressFeedback::overallPercentage
std::uint8_t overallPercentage() const
Returns the overall percentage (initially 0, supposed to be a value from 0 to 100).
Definition progressfeedback.h:86
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
TagParser::Diagnostics::has
bool has(DiagLevel level) const
Returns whether there's at least one DiagMessage which is at least as worse as level.
Definition diagnostics.cpp:42
TagParser::Diagnostics::level
DiagLevel level() const
Returns the worst diag level present in the container.
Definition diagnostics.cpp:55
TagParser::Failure
The class inherits from std::exception and serves as base class for exceptions thrown by the elements...
Definition exceptions.h:11
TagParser::Margin
The Margin class defines the four margins of a rectangle.
Definition margin.h:16
TagParser::Margin::isNull
constexpr bool isNull() const
Returns true if all margins are is 0; otherwise returns false;.
Definition margin.h:115
TagParser::MediaFileInfo
The MediaFileInfo class allows to read and write tag information providing a container/tag format ind...
Definition mediafileinfo.h:83
TagParser::MediaFileInfo::setBackupDirectory
void setBackupDirectory(std::string_view backupDirectory)
Sets the directory used to store backup files.
Definition mediafileinfo.h:430
TagParser::MediaFormat
The MediaFormat class specifies the format of media data.
Definition mediaformat.h:247
TagParser::MediaFormat::abbreviation
std::string_view abbreviation() const
Returns the abbreviation of the media format as C-style string.
Definition mediaformat.cpp:448
TagParser::MediaFormat::shortAbbreviation
std::string_view shortAbbreviation() const
Returns a short abbreviation of the media format as C-style string.
Definition mediaformat.cpp:765
TagParser::MediaFormat::name
std::string_view name() const
Returns the name of the media format as C-style string.
Definition mediaformat.cpp:17
TagParser::MediaFormat::extensionName
std::string_view extensionName() const
Returns the abbreviation of the media format as C-style string.
Definition mediaformat.cpp:1042
TagParser::OperationAbortedException
The exception that is thrown when an operation has been stopped and thus not successfully completed b...
Definition exceptions.h:46
TagParser::PositionInSet
The PositionInSet class describes the position of an element in a set which consists of a certain num...
Definition positioninset.h:21
TagParser::PositionInSet::position
constexpr std::int32_t position() const
Returns the element position of the current instance.
Definition positioninset.h:80
TagParser::PositionInSet::total
constexpr std::int32_t total() const
Returns the total element count of the current instance.
Definition positioninset.h:96
TagParser::PositionInSet::toString
StringType toString() const
Returns the string representation of the current PositionInSet.
Definition positioninset.h:129
TagParser::PositionInSet::isNull
constexpr bool isNull() const
Returns an indication whether both the element position and total element count is 0.
Definition positioninset.h:112
TagParser::ProgressFeedback
The ProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:160
TagParser::Size
The Size class defines the size of a two-dimensional object using integer point precision.
Definition size.h:17
TagParser::Size::setWidth
void setWidth(std::uint32_t value)
Sets the width.
Definition size.h:76
TagParser::Size::isNull
bool constexpr isNull() const
Returns an indication whether both the width and height is 0.
Definition size.h:100
TagParser::Size::toString
std::string toString() const
Returns the string representation of the current size.
Definition size.h:125
TagParser::Size::resolution
constexpr std::uint32_t resolution() const
Returns the resolution of the current instance (product of with and height).
Definition size.h:92
TagParser::Size::setHeight
void setHeight(std::uint32_t value)
Sets the height.
Definition size.h:84
TagParser::Size::abbreviation
std::string_view abbreviation() const
Returns an abbreviation for the current instance, eg.
Definition size.cpp:17
TagParser::TagTarget
The TagTarget class specifies the target of a tag.
Definition tagtarget.h:20
TagParser::TagTarget::level
std::uint64_t level() const
Returns the level.
Definition tagtarget.h:73
TagParser::TagTarget::toString
std::string toString(const std::function< TagTargetLevel(std::uint64_t)> &tagTargetMapping) const
Returns the string representation of the current instance.
Definition tagtarget.h:217
TagParser::TagTarget::isEmpty
bool isEmpty() const
Returns an indication whether the target is empty.
Definition tagtarget.h:169
TagParser::TagTarget::clear
void clear()
Clears the TagTarget.
Definition tagtarget.h:177
TagParser::TagTarget::setLevel
void setLevel(std::uint64_t level)
Sets the level.
Definition tagtarget.h:81
TagParser::TagTarget::setLevelName
void setLevelName(const std::string &levelName)
Sets the level name.
Definition tagtarget.h:97
UtilitiesTests
The UtilitiesTests class tests various utility classes and functions of the tagparser library.
Definition utils.cpp:37
UtilitiesTests::testPositionInSet
void testPositionInSet()
Definition utils.cpp:175
UtilitiesTests::testSize
void testSize()
Definition utils.cpp:82
UtilitiesTests::testTagTarget
void testTagTarget()
Definition utils.cpp:96
UtilitiesTests::testProgressFeedback
void testProgressFeedback()
Definition utils.cpp:202
UtilitiesTests::tearDown
void tearDown() override
Definition utils.cpp:78
UtilitiesTests::testFieldConversions
void testFieldConversions()
Tests whether field mappings are consistent.
Definition utils.cpp:401
UtilitiesTests::testStatusProvider
void testStatusProvider()
UtilitiesTests::testAbortableProgressFeedback
void testAbortableProgressFeedback()
Definition utils.cpp:241
UtilitiesTests::testAspectRatio
void testAspectRatio()
Definition utils.cpp:143
UtilitiesTests::testMargin
void testMargin()
Definition utils.cpp:135
UtilitiesTests::testSignature
void testSignature()
Definition utils.cpp:119
UtilitiesTests::testDiagnostics
void testDiagnostics()
Definition utils.cpp:284
UtilitiesTests::setUp
void setUp() override
Definition utils.cpp:74
UtilitiesTests::testBackupFile
void testBackupFile()
Definition utils.cpp:296
UtilitiesTests::testMediaFormat
void testMediaFormat()
Definition utils.cpp:157
diagnostics.h
exceptions.h
helper.h
id3v2tag.h
margin.h
mediafileinfo.h
mediaformat.h
CppUtilities
Definition abstractcontainer.h:16
TagParser::BackupHelper
Helps to create and restore backup files when rewriting files to apply changed tag information.
Definition backuphelper.h:13
TagParser::ExtensionFormats::SpectralBandReplication
@ SpectralBandReplication
Definition mediaformat.h:244
TagParser::SubFormats::AacMpeg4LowComplexityProfile
@ AacMpeg4LowComplexityProfile
Definition mediaformat.h:121
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::KnownField::Invalid
@ Invalid
Definition tag.h:38
TagParser::containerFormatSubversion
TAG_PARSER_EXPORT std::string_view containerFormatSubversion(ContainerFormat containerFormat)
Returns the subversion of the container format as C-style string.
Definition signature.cpp:508
TagParser::TagTargetLevel::Unspecified
@ Unspecified
Definition tagtarget.h:16
TagParser::TagTargetLevel::Track
@ Track
Definition tagtarget.h:16
TagParser::containerFormatAbbreviation
TAG_PARSER_EXPORT std::string_view containerFormatAbbreviation(ContainerFormat containerFormat, MediaType mediaType=MediaType::Unknown, unsigned int version=0)
Returns the abbreviation of the container format as C-style string considering the specified media ty...
Definition signature.cpp:269
TagParser::nextKnownField
constexpr KnownField nextKnownField(KnownField field)
Returns the next known field skipping any deprecated fields.
Definition tag.h:171
TagParser::containerFormatName
TAG_PARSER_EXPORT std::string_view containerFormatName(ContainerFormat containerFormat)
Returns the name of the specified container format as C-style string.
Definition signature.cpp:395
TagParser::parseSignature
TAG_PARSER_EXPORT ContainerFormat parseSignature(const char *buffer, std::size_t bufferSize)
Definition signature.h:83
TagParser::DiagLevel::Warning
@ Warning
Definition diagnostics.h:20
TagParser::DiagLevel::Critical
@ Critical
Definition diagnostics.h:21
TagParser::DiagLevel::None
@ None
Definition diagnostics.h:17
TagParser::firstKnownField
constexpr KnownField firstKnownField
The first valid entry in the TagParser::KnownField enum.
Definition tag.h:147
TagParser::GeneralMediaFormat::Aac
@ Aac
Definition mediaformat.h:32
TagParser::GeneralMediaFormat::Mpeg1Audio
@ Mpeg1Audio
Definition mediaformat.h:65
TagParser::ContainerFormat::Xz
@ Xz
Definition signature.h:65
TagParser::ContainerFormat::Unknown
@ Unknown
Definition signature.h:19
TagParser::ContainerFormat::Id3v2Tag
@ Id3v2Tag
Definition signature.h:33
positioninset.h
progressfeedback.h
signature.h
size.h
TagParser::AspectRatio
The AspectRatio struct defines an aspect ratio.
Definition aspectratio.h:13
TagParser::AspectRatio::numerator
std::uint16_t numerator
Definition aspectratio.h:22
TagParser::AspectRatio::denominator
std::uint16_t denominator
Definition aspectratio.h:23
TagParser::AspectRatio::isExtended
constexpr bool isExtended() const
Returns whether numerator and denominator must be read from extended SAR header.
Definition aspectratio.h:58
TagParser::AspectRatio::isValid
constexpr bool isValid() const
Returns an indication whether the aspect ratio is present and valid.
Definition aspectratio.h:50
tagtarget.h
CPPUNIT_TEST_SUITE_REGISTRATION
CPPUNIT_TEST_SUITE_REGISTRATION(UtilitiesTests)