Skip to content

Commit 5a6f1f9

Browse files
committed
Apply TagLib code formatting, fix static analysis issues
1 parent 6fa3db1 commit 5a6f1f9

46 files changed

Lines changed: 672 additions & 739 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/matroskareader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
2929

3030
const TagLib::Matroska::SimpleTagsList &list = tag->simpleTagsList();
3131
printf("Found %u tag(s):\n", list.size());
32-
32+
3333
for(TagLib::Matroska::SimpleTag *t : list) {
3434
PRINT_PRETTY("Tag Name", t->name().toCString(true));
3535

@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
3838
if((tString = dynamic_cast<TagLib::Matroska::SimpleTagString*>(t)))
3939
PRINT_PRETTY("Tag Value", tString->value().toCString(true));
4040
else if((tBinary = dynamic_cast<TagLib::Matroska::SimpleTagBinary*>(t)))
41-
PRINT_PRETTY("Tag Value",
41+
PRINT_PRETTY("Tag Value",
4242
TagLib::Utils::formatString("Binary with size %i", tBinary->value().size()).toCString(false)
4343
);
4444

taglib/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,21 @@ if(WITH_SHORTEN)
228228
endif()
229229
if(WITH_MATROSKA)
230230
set(tag_HDRS ${tag_HDRS}
231-
matroska/matroskafile.h
232-
matroska/matroskatag.h
233-
matroska/matroskasimpletag.h
234231
matroska/matroskaattachedfile.h
235232
matroska/matroskaattachments.h
236-
matroska/matroskafile.h
237-
matroska/matroskatag.h
238-
matroska/matroskasimpletag.h
233+
matroska/matroskacues.h
239234
matroska/matroskaelement.h
235+
matroska/matroskafile.h
236+
matroska/matroskaproperties.h
240237
matroska/matroskaseekhead.h
241238
matroska/matroskasegment.h
239+
matroska/matroskasimpletag.h
240+
matroska/matroskatag.h
242241
matroska/ebml/ebmlbinaryelement.h
243242
matroska/ebml/ebmlelement.h
244243
matroska/ebml/ebmlmasterelement.h
245244
matroska/ebml/ebmlmkattachments.h
245+
matroska/ebml/ebmlmkcues.h
246246
matroska/ebml/ebmlmkseekhead.h
247247
matroska/ebml/ebmlmksegment.h
248248
matroska/ebml/ebmlmktags.h
@@ -446,8 +446,10 @@ if(WITH_MATROSKA)
446446
set(matroska_SRCS
447447
matroska/matroskaattachedfile.cpp
448448
matroska/matroskaattachments.cpp
449+
matroska/matroskacues.cpp
449450
matroska/matroskaelement.cpp
450451
matroska/matroskafile.cpp
452+
matroska/matroskaproperties.cpp
451453
matroska/matroskaseekhead.cpp
452454
matroska/matroskasegment.cpp
453455
matroska/matroskasimpletag.cpp
@@ -459,6 +461,7 @@ if(WITH_MATROSKA)
459461
matroska/ebml/ebmlelement.cpp
460462
matroska/ebml/ebmlmasterelement.cpp
461463
matroska/ebml/ebmlmkattachments.cpp
464+
matroska/ebml/ebmlmkcues.cpp
462465
matroska/ebml/ebmlmkseekhead.cpp
463466
matroska/ebml/ebmlmksegment.cpp
464467
matroska/ebml/ebmlmktags.cpp

taglib/matroska/ebml/ebmlbinaryelement.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919
***************************************************************************/
2020

2121
#include "ebmlbinaryelement.h"
22-
#include "tfile.h"
23-
#include "tbytevector.h"
24-
#include "tdebug.h"
25-
#include <string>
22+
#include "ebmlutils.h"
2623

2724
using namespace TagLib;
2825

29-
bool EBML::BinaryElement::read(TagLib::File &file)
26+
bool EBML::BinaryElement::read(File &file)
3027
{
3128
value = file.readBlock(dataSize);
3229
if(value.size() != dataSize) {

taglib/matroska/ebml/ebmlbinaryelement.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@
2222
#define TAGLIB_EBMLBINARYELEMENT_H
2323
#ifndef DO_NOT_DOCUMENT
2424

25-
#include <cstdint>
2625
#include "ebmlelement.h"
27-
#include "ebmlutils.h"
28-
#include "tbytevector.h"
2926

3027
namespace TagLib {
3128
class File;
3229
namespace EBML {
3330
class BinaryElement : public Element
3431
{
3532
public:
36-
BinaryElement(Id id, int sizeLength, offset_t dataSize)
37-
: Element(id, sizeLength, dataSize)
38-
{}
39-
BinaryElement(Id id)
40-
: Element(id, 0, 0)
41-
{}
42-
const ByteVector& getValue() const { return value; }
33+
BinaryElement(Id id, int sizeLength, offset_t dataSize) :
34+
Element(id, sizeLength, dataSize)
35+
{
36+
}
37+
38+
explicit BinaryElement(Id id) :
39+
Element(id, 0, 0)
40+
{
41+
}
42+
const ByteVector &getValue() const { return value; }
4343
void setValue(const ByteVector &value) { this->value = value; }
4444
bool read(File &file) override;
4545
ByteVector render() override;

taglib/matroska/ebml/ebmlelement.cpp

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
using namespace TagLib;
3939

40-
EBML::Element* EBML::Element::factory(File &file)
40+
EBML::Element *EBML::Element::factory(File &file)
4141
{
4242
// Get the element ID
4343
offset_t offset = file.tell();
@@ -48,61 +48,59 @@ EBML::Element* EBML::Element::factory(File &file)
4848
}
4949

5050
// Get the size length and data length
51-
const auto& [sizeLength, dataSize] = readVINT<offset_t>(file);
51+
const auto &[sizeLength, dataSize] = readVINT<offset_t>(file);
5252
if(!sizeLength)
5353
return nullptr;
5454

5555
// Return the subclass
5656
switch(id) {
57-
case ElementIDs::EBMLHeader:
58-
return new Element(id, sizeLength, dataSize);
59-
60-
case ElementIDs::MkSegment:
61-
return new MkSegment(sizeLength, dataSize, offset);
62-
63-
case ElementIDs::MkTags:
64-
return new MkTags(sizeLength, dataSize, offset);
65-
66-
case ElementIDs::MkAttachments:
67-
return new MkAttachments(sizeLength, dataSize, offset);
68-
69-
case ElementIDs::MkTag:
70-
case ElementIDs::MkTagTargets:
71-
case ElementIDs::MkSimpleTag:
72-
case ElementIDs::MkAttachedFile:
73-
case ElementIDs::MkSeek:
74-
return new MasterElement(id, sizeLength, dataSize, offset);
75-
76-
case ElementIDs::MkTagName:
77-
case ElementIDs::MkTagString:
78-
case ElementIDs::MkAttachedFileName:
79-
case ElementIDs::MkAttachedFileDescription:
80-
return new UTF8StringElement(id, sizeLength, dataSize);
81-
82-
case ElementIDs::MkTagLanguage:
83-
case ElementIDs::MkAttachedFileMediaType:
84-
return new Latin1StringElement(id, sizeLength, dataSize);
85-
86-
case ElementIDs::MkTagTargetTypeValue:
87-
case ElementIDs::MkAttachedFileUID:
88-
case ElementIDs::MkSeekPosition:
89-
return new UIntElement(id, sizeLength, dataSize);
90-
91-
case ElementIDs::MkAttachedFileData:
92-
case ElementIDs::MkSeekID:
93-
return new BinaryElement(id, sizeLength, dataSize);
94-
95-
case ElementIDs::MkSeekHead:
96-
return new MkSeekHead(sizeLength, dataSize, offset);
97-
98-
case ElementIDs::VoidElement:
99-
return new VoidElement(sizeLength, dataSize);
100-
101-
default:
102-
return new Element(id, sizeLength, dataSize);
103-
}
57+
case ElementIDs::EBMLHeader:
58+
return new Element(id, sizeLength, dataSize);
59+
60+
case ElementIDs::MkSegment:
61+
return new MkSegment(sizeLength, dataSize, offset);
62+
63+
case ElementIDs::MkTags:
64+
return new MkTags(sizeLength, dataSize, offset);
65+
66+
case ElementIDs::MkAttachments:
67+
return new MkAttachments(sizeLength, dataSize, offset);
68+
69+
case ElementIDs::MkTag:
70+
case ElementIDs::MkTagTargets:
71+
case ElementIDs::MkSimpleTag:
72+
case ElementIDs::MkAttachedFile:
73+
case ElementIDs::MkSeek:
74+
return new MasterElement(id, sizeLength, dataSize, offset);
75+
76+
case ElementIDs::MkTagName:
77+
case ElementIDs::MkTagString:
78+
case ElementIDs::MkAttachedFileName:
79+
case ElementIDs::MkAttachedFileDescription:
80+
return new UTF8StringElement(id, sizeLength, dataSize);
81+
82+
case ElementIDs::MkTagLanguage:
83+
case ElementIDs::MkAttachedFileMediaType:
84+
return new Latin1StringElement(id, sizeLength, dataSize);
10485

105-
return nullptr;
86+
case ElementIDs::MkTagTargetTypeValue:
87+
case ElementIDs::MkAttachedFileUID:
88+
case ElementIDs::MkSeekPosition:
89+
return new UIntElement(id, sizeLength, dataSize);
90+
91+
case ElementIDs::MkAttachedFileData:
92+
case ElementIDs::MkSeekID:
93+
return new BinaryElement(id, sizeLength, dataSize);
94+
95+
case ElementIDs::MkSeekHead:
96+
return new MkSeekHead(sizeLength, dataSize, offset);
97+
98+
case ElementIDs::VoidElement:
99+
return new VoidElement(sizeLength, dataSize);
100+
101+
default:
102+
return new Element(id, sizeLength, dataSize);
103+
}
106104
}
107105

108106
EBML::Element::Id EBML::Element::readId(File &file)
@@ -124,14 +122,14 @@ EBML::Element::Id EBML::Element::readId(File &file)
124122
return buffer.toUInt(true);
125123
}
126124

127-
void EBML::Element::skipData(File &file)
125+
void EBML::Element::skipData(File &file)
128126
{
129127
file.seek(dataSize, File::Position::Current);
130128
}
131129

132130
offset_t EBML::Element::headSize() const
133-
{
134-
return EBML::idSize(id) + sizeLength;
131+
{
132+
return idSize(id) + sizeLength;
135133
}
136134

137135
ByteVector EBML::Element::render()
@@ -141,9 +139,10 @@ ByteVector EBML::Element::render()
141139
return buffer;
142140
}
143141

144-
ByteVector EBML::Element::renderId()
142+
ByteVector EBML::Element::renderId() const
145143
{
146144
int numBytes = idSize(id);
147-
id = Utils::byteSwap(id);
148-
return ByteVector((char*) &id + (4 - numBytes), numBytes);
145+
static const auto byteOrder = Utils::systemByteOrder();
146+
uint32_t data = byteOrder == Utils::LittleEndian ? Utils::byteSwap(id) : id;
147+
return ByteVector(reinterpret_cast<char *>(&data) + (4 - numBytes), numBytes);
149148
}

taglib/matroska/ebml/ebmlelement.h

Lines changed: 68 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,64 +26,77 @@
2626
#include "tutils.h"
2727
#include "taglib.h"
2828

29-
namespace TagLib {
30-
namespace EBML {
31-
class Element
29+
namespace TagLib::EBML {
30+
class Element
31+
{
32+
public:
33+
using Id = unsigned int;
34+
Element(Id id, int sizeLength, offset_t dataSize) :
35+
id(id), sizeLength(sizeLength), dataSize(dataSize)
3236
{
33-
public:
34-
using Id = unsigned int;
35-
Element(Id id, int sizeLength, offset_t dataSize)
36-
: id(id), sizeLength(sizeLength), dataSize(dataSize)
37-
{}
38-
virtual ~Element() = default;
39-
virtual bool read(File &file) {
40-
skipData(file);
41-
return true;
42-
}
43-
void skipData(File &file);
44-
Id getId() const { return id; }
45-
offset_t headSize() const;
46-
offset_t getSize() const { return headSize() + dataSize; }
47-
int getSizeLength() const { return sizeLength; }
48-
int64_t getDataSize() const { return dataSize; }
49-
ByteVector renderId();
50-
virtual ByteVector render();
51-
static Element* factory(File &file);
52-
static Id readId(File &file);
53-
54-
protected:
55-
Id id;
56-
int sizeLength;
57-
offset_t dataSize;
58-
};
37+
}
38+
virtual ~Element() = default;
39+
virtual bool read(File &file)
40+
{
41+
skipData(file);
42+
return true;
43+
}
44+
void skipData(File &file);
45+
Id getId() const { return id; }
46+
offset_t headSize() const;
47+
offset_t getSize() const { return headSize() + dataSize; }
48+
int getSizeLength() const { return sizeLength; }
49+
int64_t getDataSize() const { return dataSize; }
50+
ByteVector renderId() const;
51+
virtual ByteVector render();
52+
static Element *factory(File &file);
53+
static Id readId(File &file);
5954

60-
namespace ElementIDs {
61-
inline constexpr Element::Id EBMLHeader = 0x1A45DFA3;
62-
inline constexpr Element::Id VoidElement = 0xEC;
63-
inline constexpr Element::Id MkSegment = 0x18538067;
64-
inline constexpr Element::Id MkTags = 0x1254C367;
65-
inline constexpr Element::Id MkTag = 0x7373;
66-
inline constexpr Element::Id MkTagTargets = 0x63C0;
67-
inline constexpr Element::Id MkTagTargetTypeValue = 0x68CA;
68-
inline constexpr Element::Id MkSimpleTag = 0x67C8;
69-
inline constexpr Element::Id MkTagName = 0x45A3;
70-
inline constexpr Element::Id MkTagLanguage = 0x447A;
71-
inline constexpr Element::Id MkTagString = 0x4487;
72-
inline constexpr Element::Id MkTagsTagLanguage = 0x447A;
73-
inline constexpr Element::Id MkTagsLanguageDefault = 0x4484;
74-
inline constexpr Element::Id MkAttachments = 0x1941A469;
75-
inline constexpr Element::Id MkAttachedFile = 0x61A7;
76-
inline constexpr Element::Id MkAttachedFileDescription = 0x467E;
77-
inline constexpr Element::Id MkAttachedFileName = 0x466E;
78-
inline constexpr Element::Id MkAttachedFileMediaType = 0x4660;
79-
inline constexpr Element::Id MkAttachedFileData = 0x465C;
80-
inline constexpr Element::Id MkAttachedFileUID = 0x46AE;
81-
inline constexpr Element::Id MkSeekHead = 0x114D9B74;
82-
inline constexpr Element::Id MkSeek = 0x4DBB;
83-
inline constexpr Element::Id MkSeekID = 0x53AB;
84-
inline constexpr Element::Id MkSeekPosition = 0x53AC;
55+
protected:
56+
Id id;
57+
int sizeLength;
58+
offset_t dataSize;
59+
};
8560

86-
}
61+
namespace ElementIDs {
62+
inline constexpr Element::Id EBMLHeader = 0x1A45DFA3;
63+
inline constexpr Element::Id VoidElement = 0xEC;
64+
inline constexpr Element::Id MkSegment = 0x18538067;
65+
inline constexpr Element::Id MkTags = 0x1254C367;
66+
inline constexpr Element::Id MkTag = 0x7373;
67+
inline constexpr Element::Id MkTagTargets = 0x63C0;
68+
inline constexpr Element::Id MkTagTargetTypeValue = 0x68CA;
69+
inline constexpr Element::Id MkSimpleTag = 0x67C8;
70+
inline constexpr Element::Id MkTagName = 0x45A3;
71+
inline constexpr Element::Id MkTagLanguage = 0x447A;
72+
inline constexpr Element::Id MkTagString = 0x4487;
73+
inline constexpr Element::Id MkTagsTagLanguage = 0x447A;
74+
inline constexpr Element::Id MkTagsLanguageDefault = 0x4484;
75+
inline constexpr Element::Id MkAttachments = 0x1941A469;
76+
inline constexpr Element::Id MkAttachedFile = 0x61A7;
77+
inline constexpr Element::Id MkAttachedFileDescription = 0x467E;
78+
inline constexpr Element::Id MkAttachedFileName = 0x466E;
79+
inline constexpr Element::Id MkAttachedFileMediaType = 0x4660;
80+
inline constexpr Element::Id MkAttachedFileData = 0x465C;
81+
inline constexpr Element::Id MkAttachedFileUID = 0x46AE;
82+
inline constexpr Element::Id MkSeekHead = 0x114D9B74;
83+
inline constexpr Element::Id MkSeek = 0x4DBB;
84+
inline constexpr Element::Id MkSeekID = 0x53AB;
85+
inline constexpr Element::Id MkSeekPosition = 0x53AC;
86+
inline constexpr Element::Id MkCluster = 0x1F43B675;
87+
inline constexpr Element::Id MkCodecState = 0xA4;
88+
inline constexpr Element::Id MkCues = 0x1C53BB6B;
89+
inline constexpr Element::Id MkCuePoint = 0xBB;
90+
inline constexpr Element::Id MkCueTime = 0xB3;
91+
inline constexpr Element::Id MkCueTrackPositions = 0xB7;
92+
inline constexpr Element::Id MkCueTrack = 0xF7;
93+
inline constexpr Element::Id MkCueClusterPosition = 0xF1;
94+
inline constexpr Element::Id MkCueRelativePosition = 0xF0;
95+
inline constexpr Element::Id MkCueDuration = 0xB2;
96+
inline constexpr Element::Id MkCueBlockNumber = 0x5378;
97+
inline constexpr Element::Id MkCueCodecState = 0xEA;
98+
inline constexpr Element::Id MkCueReference = 0xDB;
99+
inline constexpr Element::Id MkCueRefTime = 0x96;
87100
}
88101
}
89102

0 commit comments

Comments
 (0)