Skip to content

Commit

Permalink
factorize the macros to declare classes
Browse files Browse the repository at this point in the history
  • Loading branch information
robUx4 committed Dec 29, 2023
1 parent 2707901 commit 074b33d
Showing 1 changed file with 32 additions and 45 deletions.
77 changes: 32 additions & 45 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,58 +170,45 @@ class EbmlElement;
#define DEFINE_SEMANTIC_ITEM_STRING(m,u,d,c) EbmlSemantic(m, u, static_cast<const char*>(d), EBML_INFO(c)),
#define DEFINE_SEMANTIC_ITEM_UTF8(m,u,d,c) EbmlSemantic(m, u, static_cast<const wchar_t*>(d), EBML_INFO(c)),

#define DECLARE_xxx_MASTER(x,DllApi) class DllApi x : public EbmlMaster { \
#define DECLARE_xxx_BASE_DEFAULT(x, DllApi, BaseClass, StorageType) \
class DllApi x : public BaseClass { \
private: \
static const EbmlCallbacks ClassInfos; \
public: \
x();
#define DECLARE_xxx_UINTEGER(x,DllApi) class DllApi x : public EbmlUInteger { \
private: \
static const EbmlCallbacksDefault<std::uint64_t> ClassInfos; \
public: \
const EbmlCallbacksDefault<std::uint64_t> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<std::uint64_t> & GetElementSpec() { return ClassInfos; } \
x();
#define DECLARE_xxx_SINTEGER(x,DllApi) class DllApi x : public EbmlSInteger { \
private: \
static const EbmlCallbacksDefault<std::int64_t> ClassInfos; \
static const EbmlCallbacksDefault<StorageType> ClassInfos; \
public: \
const EbmlCallbacksDefault<std::int64_t> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<std::int64_t> & GetElementSpec() { return ClassInfos; } \
const EbmlCallbacksDefault<StorageType> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<StorageType> & GetElementSpec() { return ClassInfos; } \
x();
#define DECLARE_xxx_STRING(x,DllApi) class DllApi x : public EbmlString { \
private: \
static const EbmlCallbacksDefault<const char *> ClassInfos; \
public: \
const EbmlCallbacksDefault<const char *> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<const char *> & GetElementSpec() { return ClassInfos; } \
x();
#define DECLARE_xxx_UNISTRING(x,DllApi) class DllApi x : public EbmlUnicodeString { \
private: \
static const EbmlCallbacksDefault<const wchar_t *> ClassInfos; \
public: \
const EbmlCallbacksDefault<const wchar_t *> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<const wchar_t *> & GetElementSpec() { return ClassInfos; } \
x();
#define DECLARE_xxx_BINARY(x,DllApi) class DllApi x : public EbmlBinary { \

#define DECLARE_xxx_BASE(x, DllApi, BaseClass) \
class DllApi x : public BaseClass { \
private: \
static const EbmlCallbacks ClassInfos; \
public: \
x();
#define DECLARE_xxx_DATE(x,DllApi) class DllApi x : public EbmlDate { \
private: \
static const EbmlCallbacksDefault<std::int64_t> ClassInfos; \
public: \
const EbmlCallbacksDefault<std::int64_t> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<std::int64_t> & GetElementSpec() { return ClassInfos; } \
x();
#define DECLARE_xxx_FLOAT(x,DllApi) class DllApi x : public EbmlFloat { \
private: \
static const EbmlCallbacksDefault<double> ClassInfos; \
public: \
const EbmlCallbacksDefault<double> & ElementSpec() const override { return ClassInfos; } \
static const EbmlCallbacksDefault<double> & GetElementSpec() { return ClassInfos; } \
x();

#define DECLARE_xxx_MASTER(x,DllApi) \
DECLARE_xxx_BASE(x, DllApi, EbmlMaster)

#define DECLARE_xxx_UINTEGER(x,DllApi) \
DECLARE_xxx_BASE_DEFAULT(x, DllApi, EbmlUInteger, std::uint64_t)

#define DECLARE_xxx_SINTEGER(x,DllApi) \
DECLARE_xxx_BASE_DEFAULT(x, DllApi, EbmlSInteger, std::int64_t)

#define DECLARE_xxx_STRING(x,DllApi) \
DECLARE_xxx_BASE_DEFAULT(x, DllApi, EbmlString, const char *)

#define DECLARE_xxx_UNISTRING(x,DllApi) \
DECLARE_xxx_BASE_DEFAULT(x, DllApi, EbmlUnicodeString, const wchar_t *)

#define DECLARE_xxx_BINARY(x,DllApi) \
DECLARE_xxx_BASE(x, DllApi, EbmlBinary)

#define DECLARE_xxx_DATE(x,DllApi) \
DECLARE_xxx_BASE_DEFAULT(x, DllApi, EbmlDate, std::int64_t)

#define DECLARE_xxx_FLOAT(x,DllApi) \
DECLARE_xxx_BASE_DEFAULT(x, DllApi, EbmlFloat, double)

#define DECLARE_EBML_MASTER(x) DECLARE_xxx_MASTER( x,EBML_DLL_API)
#define DECLARE_EBML_UINTEGER(x) DECLARE_xxx_UINTEGER(x,EBML_DLL_API)
Expand Down

0 comments on commit 074b33d

Please sign in to comment.