libebml_ng
Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
ebml::ebmlElementType Class Referenceabstract

Abstract base class for EBML Element Type objects. More...

#include <ebmlElementType.h>

Inheritance diagram for ebml::ebmlElementType:
ebml::ebmlTypeCRTP< ebmlDataType< const T >, ebmlDataElement< const T > > ebml::ebmlTypeCRTP< ebmlDataType< T >, ebmlDataElement< T > > ebml::ebmlTypeCRTP< ebmlMasterElementType, ebmlMasterElement > ebml::ebmlTypeCRTP< ebmlVoidType, ebmlVoid > ebml::ebmlDataType< const T > ebml::ebmlDataType< T > ebml::ebmlMasterElementType ebml::ebmlVoidType ebml::ebmlTypeCRTP< ebmlLazyLoadType, ebmlLazyLoad, ebmlMasterElementType > ebml::ebmlTypeCRTP< ebmlListType, ebmlList, ebmlMasterElementType > ebml::ebmlTypeCRTP< ebmlMapType< K, V, H, E, A, B >, ebmlMap< K, V, H, E, A, B >, ebmlMasterElementType > ebml::ebmlTypeCRTP< ebmlPairType< const K, V >, ebmlPair< const K, V >, ebmlMasterElementType > ebml::ebmlTypeCRTP< ebmlPairType< K, V >, ebmlPair< K, V >, ebmlMasterElementType > ebml::ebmlTypeCRTP< ebmlStructType, ebmlStruct, ebmlMasterElementType > ebml::ebmlLazyLoadType ebml::ebmlListType ebml::ebmlPairType< const K, V > ebml::ebmlPairType< K, V > ebml::ebmlStructType

Public Member Functions

 ebmlElementType (const char *ebmlID, const std::wstring &name)
 Constructor taking an EBML ID as a VINT string and an element name. More...
 
 ebmlElementType (const char *ebmlID, const std::wstring &name, const seekHelper_t *seekHelper)
 
 ebmlElementType (ebmlID_t ebmlID, const std::wstring &name)
 Constructor taking an EBML ID as an unsigned integer and an element name. More...
 
 ebmlElementType (ebmlID_t ebmlID, const std::wstring &name, const seekHelper_t *seekHelper)
 
ebml::ptr< ebmlElementoperator() () const
 Factory operator to create a default EBML element instance. More...
 
seekMapBaseinitSeekMap () const
 
seekData_tmakeSeekData (const parseString &) const
 
seekData_tmakeSeekData (const parseString &, const ebmlMasterElement_wp &) const
 
seekData_tmakeSeekData (const parseString &, ebmlMasterElement_wp &&) const
 
seekData_tmakeSeekData (const parseFile &) const
 
seekData_tmakeSeekData (const parseFile &, const ebmlMasterElement_wp &) const
 
seekData_tmakeSeekData (const parseFile &, ebmlMasterElement_wp &&) const
 
template<typename T = ebmlElementType>
T & as ()
 
template<typename T = ebmlElementType>
T & as () const
 
virtual std::wstring minirepr () const
 
std::wstring repr () const
 
Decode Functions

Decode functions for various input types.

Returns
A shared pointer to the new ebml::ebmlElement instance.
Exceptions
ebml::ebmlDecodeErrorIf there was an error decoding the data (may be subclass).
ebml::ebmlNoMatchIf the EBML ID does not match.
ebml::ebmlUnexpectedEndOfDataIf the data terminates before end of data (in either).
ebml::ebmlDataContinuesIf the data continues past expected end.
std::ios_base::failureIf an IO error occurs while attempting to read from a file.
ebml::ptr< ebmlElementdecode (const parseString &) const
 Decode element from ebml::parseString instance. More...
 
ebml::ptr< ebmlElementdecode (const parseFile &) const
 Decode and create a new EBML element instance from ebml::parseFile instance. More...
 
ebml::ptr< ebmlElementdecode (const char *, size_t) const
 Decode and create a new EBML element instance from a raw data buffer. More...
 
ebml::ptr< ebmlElementdecode (const std::string &) const
 Decode and create a new EBML element instance from a std::string instance. More...
 
ebml::ptr< ebmlElementdecode (ioBase &) const
 Decode and create a new EBML element instance from ebml::ioBase instance at the current file position. More...
 
ebml::ptr< ebmlElementdecode (ioBase &, off_t &) const
 Decode and create a new EBML element instance from ebml::ioBase instance with a specified offset. More...
 
ebml::ptr< ebmlElementdecode (ioBase &, off_t, off_t &) const
 Decode from ebml::ioBase instance with a specified offset and store the end offset. More...
 
ebml::ptr< const ebmlElementcdecode (const parseString &) const
 
ebml::ptr< const ebmlElementcdecode (const parseFile &) const
 
ebml::ptr< const ebmlElementcdecode (const char *, size_t) const
 
ebml::ptr< const ebmlElementcdecode (const std::string &) const
 
ebml::ptr< const ebmlElementcdecode (ioBase &) const
 
ebml::ptr< const ebmlElementcdecode (ioBase &, off_t &offset) const
 
ebml::ptr< const ebmlElementcdecode (ioBase &, off_t offset, off_t &end) const
 

Public Attributes

ebmlID_t ebmlID
 EBML ID associated with this element type. More...
 
std::wstring name
 Name (as a wide string) of the element type. More...
 
const seekHelper_t_seekHelper = &seekHelper
 

Protected Member Functions

virtual ebmlElement_new () const =0
 Create a default instance of an EBML element. More...
 
Decode Functions (virtual)

These functions perform the decoding assuming preliminary EBML ID checks have passed.

Parameters
parsedThe parsed EBML string (ebml::parseString) or file data (ebml::parseFile).
Returns
Raw pointer to a new ebmlElement instance.
Note
Must be implemented by derived classes.
virtual ebmlElement_decode_v (const parseString &) const =0
 
virtual ebmlElement_decode_v (const parseFile &) const =0
 
virtual ebmlElement_cdecode_v (const parseString &) const =0
 
virtual ebmlElement_cdecode_v (const parseFile &) const =0
 
Decode Functions (No Check)

These functions wrap around the virtual _decode_v functions, modifying and rethrowing any ebml::ebmlDecodeError exception thrown with EBML type and offset data set.

These functions can be used by friend classes if a manual EBML type check is performed before decoding (as is done with ebml::ebmlMasterElementType).

ebmlElement_decode_nocheck (const parseString &parsed) const
 Decode element from ebml::parseString instance. More...
 
ebmlElement_decode_nocheck (const parseFile &parsed) const
 Decode element from ebml::parseFile instance. More...
 
ebmlElement_cdecode_nocheck (const parseString &parsed) const
 
ebmlElement_cdecode_nocheck (const parseFile &parsed) const
 
Protected Decode Functions

Decode functions for various input types.

These functions perform EBML type checks and call _decode_nocheck.

Returns
Raw pointer to a new ebml::ebmlElement instance.
ebmlElement_decode (const parseString &) const
 Decode element from ebml::parseString instance. More...
 
ebmlElement_decode (const parseFile &) const
 Decode and create a new EBML element instance from ebml::parseFile instance. More...
 
ebmlElement_decode (const char *, size_t) const
 Decode from a raw data buffer. More...
 
ebmlElement_decode (const std::string &) const
 Decode from std::string. More...
 
ebmlElement_decode (ioBase &) const
 Decode and create a new EBML element instance from ebml::ioBase instance at the current file position. More...
 
ebmlElement_decode (ioBase &, off_t &) const
 Decode and create a new EBML element instance from ebml::ioBase instance with a specified offset. More...
 
ebmlElement_decode (ioBase &, off_t, off_t &) const
 Decode from ebml::ioBase instance with a specified offset and store the end offset. More...
 
ebmlElement_cdecode (const parseString &) const
 
ebmlElement_cdecode (const parseFile &) const
 
ebmlElement_cdecode (const char *, size_t) const
 
ebmlElement_cdecode (const std::string &) const
 
ebmlElement_cdecode (ioBase &) const
 
ebmlElement_cdecode (ioBase &, off_t &offset) const
 
ebmlElement_cdecode (ioBase &, off_t offset, off_t &end) const
 

Friends

class ebmlElement
 
class ebmlMasterElementType
 

Detailed Description

Abstract base class for EBML Element Type objects.

Abstract base class for EBML Element Type objects. Every subclass of ebmlElementType must have a companion subclass of ebmlElement declared as a friend class.

Instances of ebmlElementType are constructed using an EBML ID, either as an ebmlID_t (unsigned long long) or as a VINT (const char*), and a class name (unicode string).

This class declares these abstract member functions:

If you are creating an element type that encapsulates a basic data type T, consider deriving from ebml::ebmlDataType<T> and ebml::ebmlDataElement<T>.

If creating an element type that encapsulates other EBML elements, please see ebml::ebmlMasterElementType and ebml::ebmlMasterElement.

If you wish to subclass this (and ebml::ebmlElement), consider deriving directly from ebml::ebmlTypeCRTP<ebmltype_t, ebmlinst_t, typebase_t> and ebml::ebmlElementCRTP<ebmltype_t, ebmlinst_t, instbase_t>.

See also
ebml::ebmlTypeCRTP<ebmltype_t, ebmlinst_t, typebase_t>
ebml::ebmlElement

Constructor & Destructor Documentation

◆ ebmlElementType() [1/4]

ebml::ebmlElementType::ebmlElementType ( const char *  ebmlID,
const std::wstring &  name 
)
inline

Constructor taking an EBML ID as a VINT string and an element name.

Parameters
ebmlIDVINT string representing the EBML ID.
nameThe name of the EBML element type.

◆ ebmlElementType() [2/4]

ebml::ebmlElementType::ebmlElementType ( const char *  ebmlID,
const std::wstring &  name,
const seekHelper_t seekHelper 
)
inline

◆ ebmlElementType() [3/4]

ebml::ebmlElementType::ebmlElementType ( ebmlID_t  ebmlID,
const std::wstring &  name 
)
inline

Constructor taking an EBML ID as an unsigned integer and an element name.

Parameters
ebmlIDThe EBML ID value.
nameThe name of the EBML element type.

◆ ebmlElementType() [4/4]

ebml::ebmlElementType::ebmlElementType ( ebmlID_t  ebmlID,
const std::wstring &  name,
const seekHelper_t seekHelper 
)
inline

Member Function Documentation

◆ _cdecode() [1/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( const parseString parsed) const
inlineprotected

◆ _cdecode() [2/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( const parseFile parsed) const
inlineprotected

◆ _cdecode() [3/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( const char *  data,
size_t  size 
) const
inlineprotected

◆ _cdecode() [4/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( const std::string &  data) const
inlineprotected

◆ _cdecode() [5/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( ioBase file) const
inlineprotected

◆ _cdecode() [6/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( ioBase file,
off_t &  offset 
) const
inlineprotected

◆ _cdecode() [7/7]

ebmlElement * ebml::ebmlElementType::_cdecode ( ioBase file,
off_t  offset,
off_t &  end 
) const
inlineprotected

◆ _cdecode_nocheck() [1/2]

ebmlElement * ebml::ebmlElementType::_cdecode_nocheck ( const parseString parsed) const
inlineprotected

◆ _cdecode_nocheck() [2/2]

ebmlElement * ebml::ebmlElementType::_cdecode_nocheck ( const parseFile parsed) const
inlineprotected

◆ _cdecode_v() [1/2]

virtual ebmlElement* ebml::ebmlElementType::_cdecode_v ( const parseString ) const
protectedpure virtual

◆ _cdecode_v() [2/2]

virtual ebmlElement* ebml::ebmlElementType::_cdecode_v ( const parseFile ) const
protectedpure virtual

◆ _decode() [1/7]

ebmlElement * ebml::ebmlElementType::_decode ( const parseString parsed) const
inlineprotected

Decode element from ebml::parseString instance.

Parameters
parsedThe parsed EBML string.
Returns
Raw pointer to a new ebml::ebmlElement instance.

◆ _decode() [2/7]

ebmlElement * ebml::ebmlElementType::_decode ( const parseFile parsed) const
inlineprotected

Decode and create a new EBML element instance from ebml::parseFile instance.

Parameters
parsedParsing information parsed from an IO file.
Returns
Raw pointer to a new ebml::ebmlElement instance.

◆ _decode() [3/7]

ebmlElement * ebml::ebmlElementType::_decode ( const char *  data,
size_t  size 
) const
inlineprotected

Decode from a raw data buffer.

Parameters
dataPointer to the data buffer.
sizeNumber of bytes in the data buffer..
Returns
Pointer to a new ebml::ebmlElement instance.

◆ _decode() [4/7]

ebmlElement * ebml::ebmlElementType::_decode ( const std::string &  data) const
inlineprotected

Decode from std::string.

Parameters
dataString data.
Returns
Pointer to a new ebml::ebmlElement instance.

◆ _decode() [5/7]

ebmlElement * ebml::ebmlElementType::_decode ( ioBase file) const
inlineprotected

Decode and create a new EBML element instance from ebml::ioBase instance at the current file position.

Parameters
fileFile object.
Returns
Pointer to a new ebml::ebmlElement instance.

◆ _decode() [6/7]

ebmlElement * ebml::ebmlElementType::_decode ( ioBase file,
off_t &  offset 
) const
inlineprotected

Decode and create a new EBML element instance from ebml::ioBase instance with a specified offset.

Parameters
fileFile object.
offsetLocation of start of data in file.
Returns
Pointer to a new ebml::ebmlElement instance.

◆ _decode() [7/7]

ebmlElement * ebml::ebmlElementType::_decode ( ioBase file,
off_t  offset,
off_t &  endOffset 
) const
inlineprotected

Decode from ebml::ioBase instance with a specified offset and store the end offset.

Parameters
fileFile object.
offsetLocation of start of data in file.
endOffsetReference to variable to set end offset.
Returns
Pointer to a new ebml::ebmlElement instance.

◆ _decode_nocheck() [1/2]

ebmlElement * ebml::ebmlElementType::_decode_nocheck ( const parseString parsed) const
inlineprotected

Decode element from ebml::parseString instance.

Parameters
parsedThe parsed EBML string.
Returns
Raw pointer to a new ebmlElement instance.

◆ _decode_nocheck() [2/2]

ebmlElement * ebml::ebmlElementType::_decode_nocheck ( const parseFile parsed) const
inlineprotected

Decode element from ebml::parseFile instance.

Parameters
parsedThe parsed file data.
Returns
Raw pointer to a new ebmlElement instance.

◆ _decode_v() [1/2]

virtual ebmlElement* ebml::ebmlElementType::_decode_v ( const parseString ) const
protectedpure virtual

◆ _decode_v() [2/2]

virtual ebmlElement* ebml::ebmlElementType::_decode_v ( const parseFile ) const
protectedpure virtual

◆ _new()

virtual ebmlElement* ebml::ebmlElementType::_new ( ) const
protectedpure virtual

◆ as() [1/2]

template<typename T >
T & ebml::ebmlElementType::as ( )
inline

Convenience member function that dynamically casts ebmlElementType to a subclass.

Returns
Reference to instance as a T object.

Example:

ebmlElementType cls = ebmlVoidClass();
ebmlVoidClass& Void = cls.as<ebmlVoidClass>();
Exceptions
std::bad_castIf instance is not an instance of T.

◆ as() [2/2]

template<typename T >
T & ebml::ebmlElementType::as ( ) const
inline

Convenience member function that dynamically casts const ebmlElementType to a subclass.

Returns
Const reference to instance as a T object.

Example:

const ebmlElementType cls = ebmlVoidClass();
const ebmlVoidClass& Void = cls.as<ebmlVoidClass>();
Exceptions
std::bad_castIf instance is not an instance of T.

◆ cdecode() [1/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( const parseString parsed) const
inline

◆ cdecode() [2/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( const parseFile parsed) const
inline

◆ cdecode() [3/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( const char *  data,
size_t  size 
) const
inline

◆ cdecode() [4/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( const std::string &  data) const
inline

◆ cdecode() [5/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( ioBase file) const
inline

◆ cdecode() [6/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( ioBase file,
off_t &  offset 
) const
inline

◆ cdecode() [7/7]

ebml::ptr< const ebmlElement > ebml::ebmlElementType::cdecode ( ioBase file,
off_t  offset,
off_t &  end 
) const
inline

◆ decode() [1/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( const parseString parsed) const
inline

Decode element from ebml::parseString instance.

Parameters
parsedThe parsed EBML string.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ decode() [2/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( const parseFile parsed) const
inline

Decode and create a new EBML element instance from ebml::parseFile instance.

Parameters
parsedParsing information parsed from an IO file.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ decode() [3/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( const char *  data,
size_t  size 
) const
inline

Decode and create a new EBML element instance from a raw data buffer.

Parameters
dataPointer to the data buffer.
sizeNumber of bytes in the data buffer.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ decode() [4/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( const std::string &  data) const
inline

Decode and create a new EBML element instance from a std::string instance.

Parameters
dataString data.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ decode() [5/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( ioBase file) const
inline

Decode and create a new EBML element instance from ebml::ioBase instance at the current file position.

Parameters
fileFile object.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ decode() [6/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( ioBase file,
off_t &  offset 
) const
inline

Decode and create a new EBML element instance from ebml::ioBase instance with a specified offset.

Parameters
fileFile object.
offsetLocation of start of data in file.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ decode() [7/7]

ebml::ptr< ebmlElement > ebml::ebmlElementType::decode ( ioBase file,
off_t  offset,
off_t &  endOffset 
) const
inline

Decode from ebml::ioBase instance with a specified offset and store the end offset.

Parameters
fileFile object.
offsetLocation of start of data in file.
endOffsetReference to variable to set end offset.
Returns
Shared pointer to a new ebml::ebmlElement instance.

◆ initSeekMap()

seekMapBase * ebml::ebmlElementType::initSeekMap ( ) const

◆ makeSeekData() [1/6]

seekData_t * ebml::ebmlElementType::makeSeekData ( const parseString parsed) const

◆ makeSeekData() [2/6]

seekData_t * ebml::ebmlElementType::makeSeekData ( const parseString parsed,
const ebmlMasterElement_wp parent 
) const

◆ makeSeekData() [3/6]

seekData_t * ebml::ebmlElementType::makeSeekData ( const parseString parsed,
ebmlMasterElement_wp &&  parent 
) const

◆ makeSeekData() [4/6]

seekData_t * ebml::ebmlElementType::makeSeekData ( const parseFile parsed) const

◆ makeSeekData() [5/6]

seekData_t * ebml::ebmlElementType::makeSeekData ( const parseFile parsed,
const ebmlMasterElement_wp parent 
) const

◆ makeSeekData() [6/6]

seekData_t * ebml::ebmlElementType::makeSeekData ( const parseFile parsed,
ebmlMasterElement_wp &&  parent 
) const

◆ minirepr()

std::wstring ebml::ebmlElementType::minirepr ( ) const
virtual

◆ operator()()

ebml::ptr< ebmlElement > ebml::ebmlElementType::operator() ( ) const
inline

Factory operator to create a default EBML element instance.

Internally, this calls the protected _new() function.

Returns
A shared pointer to a newly created ebmlElement instance.

◆ repr()

std::wstring ebml::ebmlElementType::repr ( ) const

Friends And Related Function Documentation

◆ ebmlElement

friend class ebmlElement
friend

◆ ebmlMasterElementType

friend class ebmlMasterElementType
friend

Member Data Documentation

◆ _seekHelper

const seekHelper_t* ebml::ebmlElementType::_seekHelper = &seekHelper

◆ ebmlID

ebmlID_t ebml::ebmlElementType::ebmlID

EBML ID associated with this element type.

◆ name

std::wstring ebml::ebmlElementType::name

Name (as a wide string) of the element type.


The documentation for this class was generated from the following files: