Skip to content

Commit 68a514f

Browse files
committed
Matroska: Avoid inlined header methods, only install public headers
1 parent 607cd5b commit 68a514f

44 files changed

Lines changed: 625 additions & 181 deletions

Some content is hidden

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

taglib/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ if(WITH_MATROSKA)
7272
endif()
7373
include_directories(${tag_HDR_DIRS})
7474

75+
set(tag_PRIVATE_HDRS)
7576
set(tag_HDRS
7677
tag.h
7778
fileref.h
@@ -233,14 +234,13 @@ if(WITH_MATROSKA)
233234
matroska/matroskachapter.h
234235
matroska/matroskachapteredition.h
235236
matroska/matroskachapters.h
236-
matroska/matroskacues.h
237237
matroska/matroskaelement.h
238238
matroska/matroskafile.h
239239
matroska/matroskaproperties.h
240-
matroska/matroskaseekhead.h
241-
matroska/matroskasegment.h
242240
matroska/matroskasimpletag.h
243241
matroska/matroskatag.h
242+
)
243+
set(tag_PRIVATE_HDRS ${tag_PRIVATE_HDRS}
244244
matroska/ebml/ebmlbinaryelement.h
245245
matroska/ebml/ebmlelement.h
246246
matroska/ebml/ebmlmasterelement.h
@@ -257,6 +257,9 @@ if(WITH_MATROSKA)
257257
matroska/ebml/ebmlfloatelement.h
258258
matroska/ebml/ebmlutils.h
259259
matroska/ebml/ebmlvoidelement.h
260+
matroska/matroskacues.h
261+
matroska/matroskaseekhead.h
262+
matroska/matroskasegment.h
260263
)
261264
endif()
262265

@@ -517,7 +520,7 @@ set(tag_LIB_SRCS
517520
tagutils.cpp
518521
)
519522

520-
add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
523+
add_library(tag ${tag_LIB_SRCS} ${tag_HDRS} ${tag_PRIVATE_HDRS})
521524

522525
target_include_directories(tag INTERFACE
523526
$<INSTALL_INTERFACE:include>

taglib/matroska/ebml/ebmlbinaryelement.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,35 @@
2121
#include "ebmlbinaryelement.h"
2222
#include "ebmlutils.h"
2323
#include "tfile.h"
24+
#include "tdebug.h"
2425

2526
using namespace TagLib;
2627

28+
EBML::BinaryElement::BinaryElement(Id id, int sizeLength, offset_t dataSize):
29+
Element(id, sizeLength, dataSize)
30+
{
31+
}
32+
33+
EBML::BinaryElement::BinaryElement(Id id, int sizeLength, offset_t dataSize, offset_t):
34+
Element(id, sizeLength, dataSize)
35+
{
36+
}
37+
38+
EBML::BinaryElement::BinaryElement(Id id):
39+
Element(id, 0, 0)
40+
{
41+
}
42+
43+
const ByteVector& EBML::BinaryElement::getValue() const
44+
{
45+
return value;
46+
}
47+
48+
void EBML::BinaryElement::setValue(const ByteVector& val)
49+
{
50+
value = val;
51+
}
52+
2753
bool EBML::BinaryElement::read(File &file)
2854
{
2955
value = file.readBlock(dataSize);

taglib/matroska/ebml/ebmlbinaryelement.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,17 @@
2727

2828
namespace TagLib {
2929
class File;
30+
3031
namespace EBML {
3132
class BinaryElement : public Element
3233
{
3334
public:
34-
BinaryElement(Id id, int sizeLength, offset_t dataSize) :
35-
Element(id, sizeLength, dataSize) {}
36-
BinaryElement(Id id, int sizeLength, offset_t dataSize, offset_t) :
37-
Element(id, sizeLength, dataSize) {}
38-
explicit BinaryElement(Id id) :
39-
Element(id, 0, 0) {}
35+
BinaryElement(Id id, int sizeLength, offset_t dataSize);
36+
BinaryElement(Id id, int sizeLength, offset_t dataSize, offset_t);
37+
explicit BinaryElement(Id id);
4038

41-
const ByteVector &getValue() const { return value; }
42-
void setValue(const ByteVector &val) { value = val; }
39+
const ByteVector &getValue() const;
40+
void setValue(const ByteVector &val);
4341
bool read(File &file) override;
4442
ByteVector render() override;
4543

taglib/matroska/ebml/ebmlelement.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,54 @@ unsigned int EBML::Element::readId(File &file)
148148
return buffer.toUInt(true);
149149
}
150150

151+
EBML::Element::Element(Id id, int sizeLength, offset_t dataSize):
152+
id(id), sizeLength(sizeLength), dataSize(dataSize)
153+
{
154+
}
155+
156+
EBML::Element::Element(Id id, int sizeLength, offset_t dataSize, offset_t):
157+
id(id), sizeLength(sizeLength), dataSize(dataSize)
158+
{
159+
}
160+
161+
EBML::Element::~Element() = default;
162+
163+
bool EBML::Element::read(File& file)
164+
{
165+
skipData(file);
166+
return true;
167+
}
168+
151169
void EBML::Element::skipData(File &file)
152170
{
153171
file.seek(dataSize, File::Position::Current);
154172
}
155173

174+
EBML::Element::Id EBML::Element::getId() const
175+
{
176+
return id;
177+
}
178+
156179
offset_t EBML::Element::headSize() const
157180
{
158181
return idSize(id) + sizeLength;
159182
}
160183

184+
offset_t EBML::Element::getSize() const
185+
{
186+
return headSize() + dataSize;
187+
}
188+
189+
int EBML::Element::getSizeLength() const
190+
{
191+
return sizeLength;
192+
}
193+
194+
int64_t EBML::Element::getDataSize() const
195+
{
196+
return dataSize;
197+
}
198+
161199
ByteVector EBML::Element::render()
162200
{
163201
ByteVector buffer = renderId();

taglib/matroska/ebml/ebmlelement.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,17 @@ namespace TagLib
106106
MkChapLanguage = 0x437C,
107107
};
108108

109-
Element(Id id, int sizeLength, offset_t dataSize) :
110-
id(id), sizeLength(sizeLength), dataSize(dataSize) {}
111-
Element(Id id, int sizeLength, offset_t dataSize, offset_t) :
112-
id(id), sizeLength(sizeLength), dataSize(dataSize) {}
113-
virtual ~Element() = default;
114-
virtual bool read(File &file)
115-
{
116-
skipData(file);
117-
return true;
118-
}
109+
Element(Id id, int sizeLength, offset_t dataSize);
110+
Element(Id id, int sizeLength, offset_t dataSize, offset_t);
111+
virtual ~Element();
112+
113+
virtual bool read(File &file);
119114
void skipData(File &file);
120-
Id getId() const { return id; }
115+
Id getId() const;
121116
offset_t headSize() const;
122-
offset_t getSize() const { return headSize() + dataSize; }
123-
int getSizeLength() const { return sizeLength; }
124-
int64_t getDataSize() const { return dataSize; }
117+
offset_t getSize() const;
118+
int getSizeLength() const;
119+
int64_t getDataSize() const;
125120
ByteVector renderId() const;
126121
virtual ByteVector render();
127122
static std::unique_ptr<Element> factory(File &file);

taglib/matroska/ebml/ebmlfloatelement.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@
3131

3232
using namespace TagLib;
3333

34+
EBML::FloatElement::FloatElement(Id id, int sizeLength, offset_t dataSize):
35+
Element(id, sizeLength, dataSize)
36+
{
37+
}
38+
39+
EBML::FloatElement::FloatElement(Id id, int sizeLength, offset_t dataSize, offset_t):
40+
Element(id, sizeLength, dataSize)
41+
{
42+
}
43+
44+
EBML::FloatElement::FloatElement(Id id):
45+
FloatElement(id, 0, 0)
46+
{
47+
}
48+
49+
EBML::FloatElement::FloatVariantType EBML::FloatElement::getValue() const
50+
{ return value; }
51+
3452
double EBML::FloatElement::getValueAsDouble(double defaultValue) const
3553
{
3654
if(std::holds_alternative<double>(value)) {
@@ -42,6 +60,11 @@ double EBML::FloatElement::getValueAsDouble(double defaultValue) const
4260
return defaultValue;
4361
}
4462

63+
void EBML::FloatElement::setValue(FloatVariantType val)
64+
{
65+
value = val;
66+
}
67+
4568
bool EBML::FloatElement::read(File &file)
4669
{
4770
const ByteVector buffer = file.readBlock(dataSize);

taglib/matroska/ebml/ebmlfloatelement.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,13 @@ namespace TagLib {
3939
public:
4040
using FloatVariantType = std::variant<std::monostate, float, double>;
4141

42-
FloatElement(Id id, int sizeLength, offset_t dataSize) :
43-
Element(id, sizeLength, dataSize) {}
44-
FloatElement(Id id, int sizeLength, offset_t dataSize, offset_t) :
45-
Element(id, sizeLength, dataSize) {}
46-
explicit FloatElement(Id id) :
47-
FloatElement(id, 0, 0) {}
48-
49-
FloatVariantType getValue() const { return value; }
42+
FloatElement(Id id, int sizeLength, offset_t dataSize);
43+
FloatElement(Id id, int sizeLength, offset_t dataSize, offset_t);
44+
explicit FloatElement(Id id);
45+
46+
FloatVariantType getValue() const;
5047
double getValueAsDouble(double defaultValue = 0.0) const;
51-
void setValue(FloatVariantType val) { value = val; }
48+
void setValue(FloatVariantType val);
5249
bool read(File &file) override;
5350
ByteVector render() override;
5451

taglib/matroska/ebml/ebmlmasterelement.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,78 @@
2525

2626
using namespace TagLib;
2727

28+
EBML::MasterElement::MasterElement(Id id, int sizeLength, offset_t dataSize, offset_t offset):
29+
Element(id, sizeLength, dataSize), offset(offset)
30+
{
31+
}
32+
33+
EBML::MasterElement::MasterElement(Id id):
34+
Element(id, 0, 0), offset(0)
35+
{
36+
}
37+
2838
EBML::MasterElement::~MasterElement() = default;
2939

40+
offset_t EBML::MasterElement::getOffset() const
41+
{
42+
return offset;
43+
}
44+
3045
void EBML::MasterElement::appendElement(std::unique_ptr<Element> &&element)
3146
{
3247
elements.push_back(std::move(element));
3348
}
3449

50+
std::list<std::unique_ptr<EBML::Element>>::iterator EBML::MasterElement::begin()
51+
{
52+
return elements.begin();
53+
}
54+
55+
std::list<std::unique_ptr<EBML::Element>>::iterator EBML::MasterElement::end()
56+
{
57+
return elements.end();
58+
}
59+
60+
std::list<std::unique_ptr<EBML::Element>>::const_iterator EBML::MasterElement::begin() const
61+
{
62+
return elements.begin();
63+
}
64+
65+
std::list<std::unique_ptr<EBML::Element>>::const_iterator EBML::MasterElement::end() const
66+
{
67+
return elements.end();
68+
}
69+
70+
std::list<std::unique_ptr<EBML::Element>>::const_iterator EBML::MasterElement::cbegin() const
71+
{
72+
return elements.cbegin();
73+
}
74+
75+
std::list<std::unique_ptr<EBML::Element>>::const_iterator EBML::MasterElement::cend() const
76+
{
77+
return elements.cend();
78+
}
79+
80+
offset_t EBML::MasterElement::getPadding() const
81+
{
82+
return padding;
83+
}
84+
85+
void EBML::MasterElement::setPadding(offset_t numBytes)
86+
{
87+
padding = numBytes;
88+
}
89+
90+
offset_t EBML::MasterElement::getMinRenderSize() const
91+
{
92+
return minRenderSize;
93+
}
94+
95+
void EBML::MasterElement::setMinRenderSize(offset_t minimumSize)
96+
{
97+
minRenderSize = minimumSize;
98+
}
99+
35100
bool EBML::MasterElement::read(File &file)
36101
{
37102
const offset_t maxOffset = file.tell() + dataSize;

taglib/matroska/ebml/ebmlmasterelement.h

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

25+
#include <list>
26+
2527
#include "ebmlelement.h"
2628
#include "taglib.h"
27-
#include "tlist.h"
2829

2930
namespace TagLib
3031
{
@@ -34,26 +35,24 @@ namespace TagLib
3435
class MasterElement : public Element
3536
{
3637
public:
37-
MasterElement(Id id, int sizeLength, offset_t dataSize, offset_t offset) :
38-
Element(id, sizeLength, dataSize), offset(offset) {}
39-
explicit MasterElement(Id id) :
40-
Element(id, 0, 0), offset(0) {}
38+
MasterElement(Id id, int sizeLength, offset_t dataSize, offset_t offset);
39+
explicit MasterElement(Id id);
4140
~MasterElement() override;
4241

43-
offset_t getOffset() const { return offset; }
42+
offset_t getOffset() const;
4443
bool read(File &file) override;
4544
ByteVector render() override;
4645
void appendElement(std::unique_ptr<Element> &&element);
47-
std::list<std::unique_ptr<Element>>::iterator begin() { return elements.begin(); }
48-
std::list<std::unique_ptr<Element>>::iterator end() { return elements.end(); }
49-
std::list<std::unique_ptr<Element>>::const_iterator begin() const { return elements.begin(); }
50-
std::list<std::unique_ptr<Element>>::const_iterator end() const { return elements.end(); }
51-
std::list<std::unique_ptr<Element>>::const_iterator cbegin() const { return elements.cbegin(); }
52-
std::list<std::unique_ptr<Element>>::const_iterator cend() const { return elements.cend(); }
53-
offset_t getPadding() const { return padding; }
54-
void setPadding(offset_t numBytes) { padding = numBytes; }
55-
offset_t getMinRenderSize() const { return minRenderSize; }
56-
void setMinRenderSize(offset_t minimumSize) { minRenderSize = minimumSize; }
46+
std::list<std::unique_ptr<Element>>::iterator begin();
47+
std::list<std::unique_ptr<Element>>::iterator end();
48+
std::list<std::unique_ptr<Element>>::const_iterator begin() const;
49+
std::list<std::unique_ptr<Element>>::const_iterator end() const;
50+
std::list<std::unique_ptr<Element>>::const_iterator cbegin() const;
51+
std::list<std::unique_ptr<Element>>::const_iterator cend() const;
52+
offset_t getPadding() const;
53+
void setPadding(offset_t numBytes);
54+
offset_t getMinRenderSize() const;
55+
void setMinRenderSize(offset_t minimumSize);
5756

5857
protected:
5958
offset_t offset;

0 commit comments

Comments
 (0)