Skip to content

Commit

Permalink
simplify the EbmlSemantic constructor with any default value type
Browse files Browse the repository at this point in the history
  • Loading branch information
robUx4 committed Dec 17, 2023
1 parent 47a2e4b commit f713dd1
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,13 @@ class EBML_DLL_API EbmlCallbacks {
*/
class EBML_DLL_API EbmlSemantic {
public:
struct DefaultValues;

constexpr EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(), GetCallbacks(aGetCallbacks) {}

constexpr EbmlSemantic(bool aMandatory, bool aUnique, std::uint64_t def, const EbmlCallbacks & aCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(def), GetCallbacks(aCallbacks) {}

constexpr EbmlSemantic(bool aMandatory, bool aUnique, std::int64_t def, const EbmlCallbacks & aCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(def), GetCallbacks(aCallbacks) {}

constexpr EbmlSemantic(bool aMandatory, bool aUnique, double def, const EbmlCallbacks & aCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(def), GetCallbacks(aCallbacks) {}

constexpr EbmlSemantic(bool aMandatory, bool aUnique, const char *def, const EbmlCallbacks & aCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(def), GetCallbacks(aCallbacks) {}

constexpr EbmlSemantic(bool aMandatory, bool aUnique, const wchar_t *def, const EbmlCallbacks & aCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(def), GetCallbacks(aCallbacks) {}
constexpr EbmlSemantic(bool aMandatory, bool aUnique, const DefaultValues &def, const EbmlCallbacks & aGetCallbacks)
:Mandatory(aMandatory), Unique(aUnique), defaultValue(def), GetCallbacks(aGetCallbacks) {}

inline bool IsMandatory() const { return Mandatory; }
inline bool IsUnique() const { return Unique; }
Expand All @@ -379,6 +369,7 @@ class EBML_DLL_API EbmlSemantic {
const wchar_t* ws;
};
constexpr DefaultValues(void) : u64(0), type(DefaultType::NO_DEFAULT) {}
constexpr DefaultValues(const DefaultValues &) = default;
constexpr DefaultValues(std::uint64_t u) : u64(u), type(DefaultType::UINTEGER) {}
constexpr DefaultValues(std::int64_t u) : u64(u), type(DefaultType::UINTEGER) {}
constexpr DefaultValues(double d) : f(d), type(DefaultType::DOUBLE) {}
Expand Down

0 comments on commit f713dd1

Please sign in to comment.