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