libebml_ng
Core Concepts: EBML Element Types and Instances

Overview of the Public Interface

The EBML library is designed with a clear separation between an element's metadata and factory functionality (the *type**) and its actual data and behavior (the instance). This allows you to:

The core public interfaces are defined in the abstract classes:

Notice that the public interface intentionally abstracts away complex internal details. The protected and private member functions focus on the implementation details of instance creation, decoding, and memory management.

Subclassing: Implementing a Fully Functional EBML Element

To implement a new EBML element, you typically define a subclass pair:

This section outlines the essential requirements and optional recommendations for successfully implementing these subclasses.

A pair of CRTP templates ebml::ebmlTypeCRTP<ebmltype_t, ebmlinst_t, typebase_t> and ebml::ebmlElementCRTP<ebmltype_t, ebmlinst_t, instbase_t> are provided to help simplify the process of subclassing ebml::ebmlElementType and ebml::ebmlElement. See The CRTP Design Pattern for more information.

Requirements for `ebmltype_t` (Element Type Subclass)

It is still possible, however, to subclass directly from ebml::ebmlElementType and ebml::ebmlElement. To do this, in your element type subclass, you must implement the following protected virtual functions:

Requirements for `ebmlinst_t` (Element Instance Subclass)

Your element instance subclass must at a minimum implement:

Summary

This design encourages a robust, type-safe approach to working with EBML data, making it accessible to both new and experienced C++ developers.

See also
The CRTP Design Pattern
Data Type Templates: Creating Custom EBML Data Types