Skip to content

Commit c9d3dc0

Browse files
robUx4mbunkus
authored andcommitted
always compile in strict API mode
All the members become private. This requires libmatroska to merge Matroska-Org/libmatroska#95
1 parent 35f391b commit c9d3dc0

14 files changed

+0
-117
lines changed

ebml/EbmlBinary.h

-4
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ class EBML_DLL_API EbmlBinary : public EbmlElement {
8888

8989
bool operator==(const EbmlBinary & ElementToCompare) const;
9090

91-
#if defined(EBML_STRICT_API)
9291
private:
93-
#else
94-
protected:
95-
#endif
9692
binary *Data{nullptr}; // the binary data inside the element
9793
};
9894

ebml/EbmlCrc32.h

-4
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ DECLARE_EBML_BINARY(EbmlCrc32)
8585

8686
void ForceCrc32(std::uint32_t NewValue) { m_crc_final = NewValue; SetValueIsSet();}
8787

88-
#if defined(EBML_STRICT_API)
8988
private:
90-
#else
91-
protected:
92-
#endif
9389
void ResetCRC();
9490
void UpdateByte(binary b);
9591

ebml/EbmlDate.h

-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
8282
return false;
8383
}
8484

85-
#if defined(EBML_STRICT_API)
8685
private:
87-
#else
88-
protected:
89-
#endif
9086
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false) override;
9187

9288
std::int64_t myDate{0}; ///< internal format of the date

ebml/EbmlDummy.h

-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ class EBML_DLL_API EbmlDummy : public EbmlBinary {
5252
return DummyId;
5353
}
5454

55-
#if defined(EBML_STRICT_API)
5655
private:
57-
#else
58-
protected:
59-
#endif
6056
const EbmlId DummyId;
6157
static const EbmlId DummyRawId;
6258

ebml/EbmlElement.h

-58
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ extern const EbmlSemanticContext Context_EbmlGlobal;
176176
public: \
177177
x();
178178

179-
#if defined(EBML_STRICT_API)
180179
#define EBML_CONCRETE_CLASS(Type) \
181180
public: \
182181
const EbmlSemanticContext &Context() const override {return ClassInfos.GetContext();} \
@@ -225,50 +224,6 @@ extern const EbmlSemanticContext Context_EbmlGlobal;
225224
#define EBML_CTX_IDX(c,i) (c).GetSemantic(i)
226225
#define EBML_CTX_IDX_INFO(c,i) (const EbmlCallbacks &)((c).GetSemantic(i))
227226
#define EBML_CTX_IDX_ID(c,i) ((const EbmlCallbacks &)((c).GetSemantic(i))).ClassId()
228-
#else
229-
#define EBML_CONCRETE_CLASS(Type) \
230-
public: \
231-
const EbmlCallbacks & Generic() const override {return ClassInfos;} \
232-
operator const EbmlId &() const override {return ClassInfos.GlobalId;} \
233-
EbmlElement & CreateElement() const override {return Create();} \
234-
EbmlElement * Clone() const override { return new Type(*this); } \
235-
static EbmlElement & Create() {return *(new (Type));} \
236-
static const EbmlCallbacks ClassInfos; \
237-
238-
#define EBML_CONCRETE_DUMMY_CLASS(Type) \
239-
public: \
240-
const EbmlCallbacks & Generic() const override {return ClassInfos;} \
241-
virtual operator const EbmlId &(); \
242-
EbmlElement & CreateElement() const override {return Create();} \
243-
EbmlElement * Clone() const override { return new Type(*this); } \
244-
static EbmlElement & Create() {return *(new (Type));} \
245-
static const EbmlCallbacks ClassInfos; \
246-
247-
248-
#define EBML_INFO(ref) ref::ClassInfos
249-
#define EBML_ID(ref) ref::ClassInfos.GlobalId
250-
#define EBML_CLASS_SEMCONTEXT(ref) Context_##ref
251-
#define EBML_CLASS_CONTEXT(ref) ref::ClassInfos.Context
252-
#define EBML_CLASS_CALLBACK(ref) ref::ClassInfos
253-
#define EBML_CONTEXT(e) (e)->Generic().Context
254-
#define EBML_NAME(e) (e)->Generic().DebugName
255-
256-
#define EBML_INFO_ID(cb) (cb).GlobalId
257-
#define EBML_INFO_NAME(cb) (cb).DebugName
258-
#define EBML_INFO_CREATE(cb) (cb).Create()
259-
#define EBML_INFO_CONTEXT(cb) (cb).Context
260-
261-
#define EBML_SEM_UNIQUE(s) (s).Unique
262-
#define EBML_SEM_CONTEXT(s) (s).GetCallbacks.Context
263-
#define EBML_SEM_CREATE(s) (s).Create()
264-
265-
#define EBML_CTX_SIZE(c) (c).Size
266-
#define EBML_CTX_MASTER(c) (c).MasterElt
267-
#define EBML_CTX_PARENT(c) (c).UpTable
268-
#define EBML_CTX_IDX(c,i) (c).MyTable[(i)]
269-
#define EBML_CTX_IDX_INFO(c,i) (c).MyTable[(i)].GetCallbacks
270-
#define EBML_CTX_IDX_ID(c,i) (c).MyTable[(i)].GetCallbacks.GlobalId
271-
#endif
272227

273228
#if !defined(INVALID_FILEPOS_T)
274229
#define INVALID_FILEPOS_T 0
@@ -298,9 +253,7 @@ class EBML_DLL_API EbmlCallbacks {
298253
inline const char * GetName() const { return DebugName; }
299254
inline EbmlElement & NewElement() const { return Create(); }
300255

301-
#if defined(EBML_STRICT_API)
302256
private:
303-
#endif
304257
EbmlElement & (*Create)();
305258
const EbmlId & GlobalId;
306259
const char * DebugName;
@@ -321,9 +274,7 @@ class EBML_DLL_API EbmlSemantic {
321274
inline EbmlElement & Create() const { return EBML_INFO_CREATE(GetCallbacks); }
322275
inline explicit operator const EbmlCallbacks &() const { return GetCallbacks; }
323276

324-
#if defined(EBML_STRICT_API)
325277
private:
326-
#endif
327278
bool Mandatory; ///< wether the element is mandatory in the context or not
328279
bool Unique;
329280
const EbmlCallbacks & GetCallbacks;
@@ -358,9 +309,7 @@ class EBML_DLL_API EbmlSemanticContext {
358309

359310
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
360311

361-
#if defined(EBML_STRICT_API)
362312
private:
363-
#endif
364313
const EbmlSemantic *MyTable; ///< First element in the table
365314
std::size_t Size; ///< number of elements in the table
366315
const EbmlSemanticContext *UpTable; ///< Parent element
@@ -399,13 +348,8 @@ class EBML_DLL_API EbmlElement {
399348
virtual EbmlElement * Clone() const = 0;
400349

401350
virtual explicit operator const EbmlId &() const = 0;
402-
#if defined(EBML_STRICT_API)
403351
virtual const char *DebugName() const = 0;
404352
virtual const EbmlSemanticContext &Context() const = 0;
405-
#else
406-
/// return the generic callback to monitor a derived class
407-
virtual const EbmlCallbacks & Generic() const = 0;
408-
#endif
409353
virtual EbmlElement & CreateElement() const = 0;
410354

411355
// by default only allow to set element as finite (override when needed)
@@ -501,9 +445,7 @@ class EBML_DLL_API EbmlElement {
501445
inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;}
502446
inline std::uint64_t GetSizePosition() const {return SizePosition;}
503447

504-
#if defined(EBML_STRICT_API)
505448
private:
506-
#endif
507449
std::uint64_t Size; ///< the size of the data to write
508450
std::uint64_t DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal)
509451
int SizeLength{0}; /// the minimum size on which the size will be written (0 = optimal)

ebml/EbmlEndian.h

-4
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ template<class TYPE, endianess ENDIAN> class Endian
212212
inline std::size_t size() const { return sizeof(TYPE); }
213213
inline bool operator!=(const binary *buffer) const {return *(reinterpret_cast<TYPE*>(buffer)) == platform_value;}
214214

215-
#if defined(EBML_STRICT_API)
216215
private:
217-
#else
218-
protected:
219-
#endif
220216
TYPE platform_value;
221217
TYPE endian_value;
222218

ebml/EbmlFloat.h

-4
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ class EBML_DLL_API EbmlFloat : public EbmlElement {
9292
return (DefaultISset() && Value == DefaultValue);
9393
}
9494

95-
#if defined(EBML_STRICT_API)
9695
private:
97-
#else
98-
protected:
99-
#endif
10096
double Value; /// The actual value of the element
10197
double DefaultValue;
10298
};

ebml/EbmlId.h

-7
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@
4141
namespace libebml {
4242

4343

44-
#if defined(EBML_STRICT_API)
4544
#define EBML_ID_VALUE(id) (id).GetValue()
4645
#define EBML_ID_LENGTH(id) (id).GetLength()
47-
#else
48-
#define EBML_ID_VALUE(id) (id).Value
49-
#define EBML_ID_LENGTH(id) (id).Length
50-
#endif
5146

5247
/*!
5348
\class EbmlId
@@ -86,9 +81,7 @@ class EBML_DLL_API EbmlId {
8681
inline std::size_t GetLength() const { return Length; }
8782
inline std::uint32_t GetValue() const { return Value; }
8883

89-
#if defined(EBML_STRICT_API)
9084
private:
91-
#endif
9285
std::uint32_t Value;
9386
std::size_t Length;
9487
};

ebml/EbmlMaster.h

-4
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
178178
*/
179179
std::vector<std::string> FindAllMissingElements() const;
180180

181-
#if defined(EBML_STRICT_API)
182181
private:
183-
#else
184-
protected:
185-
#endif
186182
std::vector<EbmlElement *> ElementList;
187183

188184
const EbmlSemanticContext & Context;

ebml/EbmlSInteger.h

-4
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ class EBML_DLL_API EbmlSInteger : public EbmlElement {
8686
return (DefaultISset() && Value == DefaultValue);
8787
}
8888

89-
#if defined(EBML_STRICT_API)
9089
private:
91-
#else
92-
protected:
93-
#endif
9490
std::int64_t Value; /// The actual value of the element
9591
std::int64_t DefaultValue;
9692
};

ebml/EbmlStream.h

-4
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ class EBML_DLL_API EbmlStream {
6161
inline IOCallback & I_O() {return Stream;}
6262
operator IOCallback &() {return Stream;}
6363

64-
#if defined(EBML_STRICT_API)
6564
private:
66-
#else
67-
protected:
68-
#endif
6965
IOCallback & Stream;
7066
};
7167

ebml/EbmlString.h

-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ class EBML_DLL_API EbmlString : public EbmlElement {
7171
return (DefaultISset() && Value == DefaultValue);
7272
}
7373

74-
#if defined(EBML_STRICT_API)
7574
private:
76-
#else
77-
protected:
78-
#endif
7975
std::string Value; /// The actual value of the element
8076
std::string DefaultValue;
8177
};

ebml/EbmlUInteger.h

-4
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ class EBML_DLL_API EbmlUInteger : public EbmlElement {
8484
return (DefaultISset() && Value == DefaultValue);
8585
}
8686

87-
#if defined(EBML_STRICT_API)
8887
private:
89-
#else
90-
protected:
91-
#endif
9288
std::uint64_t Value; /// The actual value of the element
9389
std::uint64_t DefaultValue;
9490
};

ebml/EbmlUnicodeString.h

-8
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ class EBML_DLL_API UTFstring {
7878
const std::string & GetUTF8() const {return UTF8string;}
7979
void SetUTF8(const std::string &);
8080

81-
#if defined(EBML_STRICT_API)
8281
private:
83-
#else
84-
protected:
85-
#endif
8682
std::size_t _Length{0}; ///< length of the UCS string excluding the \0
8783
wchar_t* _Data{nullptr}; ///< internal UCS representation
8884
std::string UTF8string;
@@ -123,11 +119,7 @@ class EBML_DLL_API EbmlUnicodeString : public EbmlElement {
123119
return (DefaultISset() && Value == DefaultValue);
124120
}
125121

126-
#if defined(EBML_STRICT_API)
127122
private:
128-
#else
129-
protected:
130-
#endif
131123
UTFstring Value; /// The actual value of the element
132124
UTFstring DefaultValue;
133125
};

0 commit comments

Comments
 (0)