Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
TagParser::GenericFileElement< ImplementationType > Class Template Reference

The GenericFileElement class helps to parse binary files which consist of an arboreal element structure. More...

#include <genericfileelement.h>

Collaboration diagram for TagParser::GenericFileElement< ImplementationType >:
[legend]

Public Types

using ContainerType = typename FileElementTraits<ImplementationType>::ContainerType
 Specifies the type of the corresponding container.
 
using IdentifierType = typename FileElementTraits<ImplementationType>::IdentifierType
 Specifies the type used to store identifiers.
 
using DataSizeType = typename FileElementTraits<ImplementationType>::DataSizeType
 Specifies the type used to store data sizes.
 

Public Member Functions

 GenericFileElement (ContainerType &container, std::uint64_t startOffset)
 
 GenericFileElement (ImplementationType &parent, std::uint64_t startOffset)
 Constructs a new sub level file element with the specified parent at the specified startOffset.
 
 GenericFileElement (ContainerType &container, std::uint64_t startOffset, std::uint64_t maxSize)
 
 GenericFileElement (const GenericFileElement &other)=delete
 
 GenericFileElement (GenericFileElement &other)=delete
 
GenericFileElementoperator= (const GenericFileElement &other)=delete
 
ContainerTypecontainer ()
 Returns the related container.
 
const ContainerTypecontainer () const
 Returns the related container.
 
std::iostream & stream ()
 Returns the related stream.
 
CppUtilities::BinaryReader & reader ()
 Returns the related BinaryReader.
 
CppUtilities::BinaryWriter & writer ()
 Returns the related BinaryWriter.
 
std::uint64_t startOffset () const
 Returns the start offset in the related stream.
 
std::uint64_t relativeStartOffset () const
 Returns the offset of the element in its parent or - if it is a top-level element - in the related stream.
 
const IdentifierTypeid () const
 Returns the element ID.
 
std::string idToString () const
 Returns a printable string representation of the element ID.
 
std::uint32_t idLength () const
 Returns the length of the id denotation in byte.
 
std::uint32_t headerSize () const
 Returns the header size of the element in byte.
 
DataSizeType dataSize () const
 Returns the data size of the element in byte.
 
std::uint32_t sizeLength () const
 Returns the length of the size denotation of the element in byte.
 
std::uint64_t dataOffset () const
 Returns the data offset of the element in the related stream.
 
std::uint64_t totalSize () const
 Returns the total size of the element.
 
std::uint64_t endOffset () const
 Returns the offset of the first byte which doesn't belong to this element anymore.
 
std::uint64_t maxTotalSize () const
 Returns maximum total size.
 
std::uint8_t level () const
 Returns how deep the element is nested (0 for top-level elements, 1 for children of top-level elements, ...).
 
ImplementationType * parent ()
 Returns the parent of the element.
 
const ImplementationType * parent () const
 Returns the parent of the element.
 
ImplementationType * parent (std::uint8_t n)
 Returns the n-th parent of the element.
 
const ImplementationType * parent (std::uint8_t n) const
 Returns the n-th parent of the element.
 
ImplementationType * nextSibling ()
 Returns the next sibling of the element.
 
const ImplementationType * nextSibling () const
 Returns the next sibling of the element.
 
ImplementationType * firstChild ()
 Returns the first child of the element.
 
const ImplementationType * firstChild () const
 Returns the first child of the element.
 
ImplementationType * lastChild ()
 Returns the last child of the element.
 
const ImplementationType * lastChild () const
 Returns the last child of the element.
 
template<class IdType >
ImplementationType * subelementByPath (Diagnostics &diag, IdType item)
 Returns the sub element for the specified path.
 
template<class IdType , class... IdTypes>
ImplementationType * subelementByPath (Diagnostics &diag, IdType item, IdTypes... remainingPath)
 Returns the sub element for the specified path.
 
template<class IdType >
const ImplementationType * subelementByPath (Diagnostics &diag, IdType item) const
 Returns the sub element for the specified path.
 
template<class IdType , class... IdTypes>
const ImplementationType * subelementByPath (Diagnostics &diag, IdType item, IdTypes... remainingPath) const
 Returns the sub element for the specified path.
 
ImplementationType * childById (const IdentifierType &id, Diagnostics &diag)
 Returns the first child with the specified id.
 
const ImplementationType * childById (const IdentifierType &id, Diagnostics &diag) const
 Returns the first child with the specified id.
 
ImplementationType * siblingById (const IdentifierType &id, Diagnostics &diag)
 Returns the first sibling with the specified id.
 
const ImplementationType * siblingById (const IdentifierType &id, Diagnostics &diag) const
 Returns the first sibling with the specified id.
 
ImplementationType * siblingByIdIncludingThis (const IdentifierType &id, Diagnostics &diag)
 Returns the first sibling with the specified id or the current instance if its ID equals id.
 
const ImplementationType * siblingByIdIncludingThis (const IdentifierType &id, Diagnostics &diag) const
 Returns the first sibling with the specified id or the current instance if its ID equals id.
 
bool isParent () const
 Returns an indication whether this instance is a parent element.
 
bool isPadding () const
 Returns an indication whether this instance is a padding element.
 
std::uint64_t firstChildOffset () const
 Returns the offset of the first child (relative to the start offset of this element).
 
bool isParsed () const
 Returns an indication whether this instance has been parsed yet.
 
void clear ()
 Clears the status of the element.
 
void parse (Diagnostics &diag)
 Parses the header information of the element which is read from the related stream at the start offset.
 
void reparse (Diagnostics &diag)
 Parses the header information of the element which is read from the related stream at the start offset.
 
void validateSubsequentElementStructure (Diagnostics &diag, std::uint64_t *paddingSize=nullptr, AbortableProgressFeedback *progress=nullptr)
 Parses (see parse()) this and all subsequent elements.
 
template<typename TargetStream = std::ostream>
void copyHeader (TargetStream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
 Writes the header information of the element to the specified targetStream.
 
template<typename TargetStream = std::ostream>
void copyWithoutChilds (TargetStream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
 Writes the element without its children to the specified targetStream.
 
template<typename TargetStream = std::ostream>
void copyEntirely (TargetStream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
 Writes the entire element including all children to the specified targetStream.
 
void makeBuffer ()
 Buffers the element (header and data).
 
void discardBuffer ()
 Discards buffered data.
 
template<typename TargetStream = std::ostream>
void copyBuffer (TargetStream &targetStream)
 Copies buffered data to targetStream.
 
template<typename TargetStream = std::ostream>
void copyPreferablyFromBuffer (TargetStream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
 Copies buffered data to targetStream if data has been buffered; copies from input stream otherwise.
 
const std::unique_ptr< char[]> & buffer ()
 Returns buffered data.
 
ImplementationType * denoteFirstChild (std::uint32_t offset)
 Denotes the first child to start at the specified offset (relative to the start offset of this descriptor).
 

Static Public Member Functions

static constexpr std::uint32_t maximumIdLengthSupported ()
 Returns the maximum id length supported by the class in byte.
 
static constexpr std::uint32_t maximumSizeLengthSupported ()
 Returns the maximum size length supported by the class in byte.
 
static constexpr std::uint8_t minimumElementSize ()
 Returns the minimum element size.
 

Protected Attributes

IdentifierType m_id
 
std::uint64_t m_startOffset
 
std::uint64_t m_maxSize
 
DataSizeType m_dataSize
 
std::uint32_t m_idLength
 
std::uint32_t m_sizeLength
 
ImplementationType * m_parent
 
std::unique_ptr< ImplementationType > m_nextSibling
 
std::unique_ptr< ImplementationType > m_firstChild
 
std::unique_ptr< char[]> m_buffer
 
bool m_sizeUnknown
 

Friends

class FileElementTraits< ImplementationType >
 

Detailed Description

template<class ImplementationType>
class TagParser::GenericFileElement< ImplementationType >

The GenericFileElement class helps to parse binary files which consist of an arboreal element structure.

Template Parameters
ImplementationTypeSpecifies the type of the actual implementation.
Remarks
This template class is intended to be subclassed using with the "Curiously recurring template pattern".

Member Typedef Documentation

◆ ContainerType

template<class ImplementationType >
using TagParser::GenericFileElement< ImplementationType >::ContainerType = typename FileElementTraits<ImplementationType>::ContainerType

Specifies the type of the corresponding container.

Definition at line 51 of file genericfileelement.h.

◆ DataSizeType

template<class ImplementationType >
using TagParser::GenericFileElement< ImplementationType >::DataSizeType = typename FileElementTraits<ImplementationType>::DataSizeType

Specifies the type used to store data sizes.

Definition at line 61 of file genericfileelement.h.

◆ IdentifierType

template<class ImplementationType >
using TagParser::GenericFileElement< ImplementationType >::IdentifierType = typename FileElementTraits<ImplementationType>::IdentifierType

Specifies the type used to store identifiers.

Definition at line 56 of file genericfileelement.h.

Constructor & Destructor Documentation

◆ GenericFileElement() [1/5]

template<class ImplementationType >
TagParser::GenericFileElement< ImplementationType >::GenericFileElement ( ContainerType & container,
std::uint64_t startOffset )

◆ GenericFileElement() [2/5]

template<class ImplementationType >
TagParser::GenericFileElement< ImplementationType >::GenericFileElement ( ImplementationType & parent,
std::uint64_t startOffset )

Constructs a new sub level file element with the specified parent at the specified startOffset.

Definition at line 188 of file genericfileelement.h.

◆ GenericFileElement() [3/5]

template<class ImplementationType >
TagParser::GenericFileElement< ImplementationType >::GenericFileElement ( ContainerType & container,
std::uint64_t startOffset,
std::uint64_t maxSize )

◆ GenericFileElement() [4/5]

template<class ImplementationType >
TagParser::GenericFileElement< ImplementationType >::GenericFileElement ( const GenericFileElement< ImplementationType > & other)
delete

◆ GenericFileElement() [5/5]

template<class ImplementationType >
TagParser::GenericFileElement< ImplementationType >::GenericFileElement ( GenericFileElement< ImplementationType > & other)
delete

Member Function Documentation

◆ buffer()

template<class ImplementationType >
const std::unique_ptr< char[]> & TagParser::GenericFileElement< ImplementationType >::buffer ( )
inline

Returns buffered data.

The returned array is totalSize() bytes long.

Remarks
Data must have been buffered using the makeBuffer() method.

Definition at line 928 of file genericfileelement.h.

◆ childById() [1/2]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::childById ( const IdentifierType & id,
Diagnostics & diag )

Returns the first child with the specified id.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned.

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 610 of file genericfileelement.h.

◆ childById() [2/2]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::childById ( const IdentifierType & id,
Diagnostics & diag ) const

Returns the first child with the specified id.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned.

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 632 of file genericfileelement.h.

◆ clear()

template<class ImplementationType >
void TagParser::GenericFileElement< ImplementationType >::clear ( )

Clears the status of the element.

Resets id length, data size, size length to zero. Subsequent elements will be deleted.

Definition at line 753 of file genericfileelement.h.

◆ container() [1/2]

template<class ImplementationType >
GenericFileElement< ImplementationType >::ContainerType & TagParser::GenericFileElement< ImplementationType >::container ( )
inline

Returns the related container.

Definition at line 225 of file genericfileelement.h.

◆ container() [2/2]

template<class ImplementationType >
const GenericFileElement< ImplementationType >::ContainerType & TagParser::GenericFileElement< ImplementationType >::container ( ) const
inline

Returns the related container.

Definition at line 234 of file genericfileelement.h.

◆ copyBuffer()

template<class ImplementationType >
template<typename TargetStream >
void TagParser::GenericFileElement< ImplementationType >::copyBuffer ( TargetStream & targetStream)
inline

Copies buffered data to targetStream.

Remarks
Data must have been buffered using the makeBuffer() method.

Definition at line 907 of file genericfileelement.h.

◆ copyEntirely()

template<class ImplementationType >
template<typename TargetStream >
void TagParser::GenericFileElement< ImplementationType >::copyEntirely ( TargetStream & targetStream,
Diagnostics & diag,
AbortableProgressFeedback * progress )

Writes the entire element including all children to the specified targetStream.

Definition at line 877 of file genericfileelement.h.

◆ copyHeader()

template<class ImplementationType >
template<typename TargetStream >
void TagParser::GenericFileElement< ImplementationType >::copyHeader ( TargetStream & targetStream,
Diagnostics & diag,
AbortableProgressFeedback * progress )

Writes the header information of the element to the specified targetStream.

Definition at line 853 of file genericfileelement.h.

◆ copyPreferablyFromBuffer()

template<class ImplementationType >
template<typename TargetStream >
void TagParser::GenericFileElement< ImplementationType >::copyPreferablyFromBuffer ( TargetStream & targetStream,
Diagnostics & diag,
AbortableProgressFeedback * progress )
inline

Copies buffered data to targetStream if data has been buffered; copies from input stream otherwise.

Remarks
So this is copyBuffer() with a fallback to copyEntirely().

Definition at line 918 of file genericfileelement.h.

◆ copyWithoutChilds()

template<class ImplementationType >
template<typename TargetStream >
void TagParser::GenericFileElement< ImplementationType >::copyWithoutChilds ( TargetStream & targetStream,
Diagnostics & diag,
AbortableProgressFeedback * progress )

Writes the element without its children to the specified targetStream.

Definition at line 863 of file genericfileelement.h.

◆ dataOffset()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::dataOffset ( ) const
inline

Returns the data offset of the element in the related stream.

This is the sum of start offset and header size.

Definition at line 338 of file genericfileelement.h.

◆ dataSize()

template<class ImplementationType >
GenericFileElement< ImplementationType >::DataSizeType TagParser::GenericFileElement< ImplementationType >::dataSize ( ) const
inline

Returns the data size of the element in byte.

This is the size of the element excluding the header.

Definition at line 320 of file genericfileelement.h.

◆ denoteFirstChild()

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::denoteFirstChild ( std::uint32_t relativeFirstChildOffset)

Denotes the first child to start at the specified offset (relative to the start offset of this descriptor).

Remarks
A new first child is constructed. A possibly existing subtree is invalidated.

Definition at line 967 of file genericfileelement.h.

◆ discardBuffer()

template<class ImplementationType >
void TagParser::GenericFileElement< ImplementationType >::discardBuffer ( )
inline

Discards buffered data.

Definition at line 896 of file genericfileelement.h.

◆ endOffset()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::endOffset ( ) const
inline

Returns the offset of the first byte which doesn't belong to this element anymore.

Definition at line 356 of file genericfileelement.h.

◆ firstChild() [1/2]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::firstChild ( )
inline

Returns the first child of the element.

The current element keeps ownership over the returned element. If no children are present nullptr is returned.

Remarks
parse() needs to be called before.

Definition at line 465 of file genericfileelement.h.

◆ firstChild() [2/2]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::firstChild ( ) const
inline

Returns the first child of the element.

The current element keeps ownership over the returned element. If no children are present nullptr is returned.

Remarks
parse() needs to be called before.

Definition at line 478 of file genericfileelement.h.

◆ firstChildOffset()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::firstChildOffset ( ) const
inline

Returns the offset of the first child (relative to the start offset of this element).

Definition at line 734 of file genericfileelement.h.

◆ headerSize()

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::headerSize ( ) const
inline

Returns the header size of the element in byte.

This is the sum of the id length and the size length.

Definition at line 309 of file genericfileelement.h.

◆ id()

template<class ImplementationType >
const GenericFileElement< ImplementationType >::IdentifierType & TagParser::GenericFileElement< ImplementationType >::id ( ) const
inline

Returns the element ID.

Definition at line 283 of file genericfileelement.h.

◆ idLength()

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::idLength ( ) const
inline

Returns the length of the id denotation in byte.

Definition at line 299 of file genericfileelement.h.

◆ idToString()

template<class ImplementationType >
std::string TagParser::GenericFileElement< ImplementationType >::idToString ( ) const
inline

Returns a printable string representation of the element ID.

Definition at line 291 of file genericfileelement.h.

◆ isPadding()

template<class ImplementationType >
bool TagParser::GenericFileElement< ImplementationType >::isPadding ( ) const
inline

Returns an indication whether this instance is a padding element.

Definition at line 726 of file genericfileelement.h.

◆ isParent()

template<class ImplementationType >
bool TagParser::GenericFileElement< ImplementationType >::isParent ( ) const
inline

Returns an indication whether this instance is a parent element.

Definition at line 718 of file genericfileelement.h.

◆ isParsed()

template<class ImplementationType >
bool TagParser::GenericFileElement< ImplementationType >::isParsed ( ) const
inline

Returns an indication whether this instance has been parsed yet.

Definition at line 742 of file genericfileelement.h.

◆ lastChild() [1/2]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::lastChild ( )
inline

Returns the last child of the element.

The current element keeps ownership over the returned element. If no children are present nullptr is returned.

Remarks
parse() needs to be called before.

Definition at line 491 of file genericfileelement.h.

◆ lastChild() [2/2]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::lastChild ( ) const
inline

Returns the last child of the element.

The current element keeps ownership over the returned element. If no children are present nullptr is returned.

Remarks
parse() needs to be called before.

Definition at line 509 of file genericfileelement.h.

◆ level()

template<class ImplementationType >
std::uint8_t TagParser::GenericFileElement< ImplementationType >::level ( ) const

Returns how deep the element is nested (0 for top-level elements, 1 for children of top-level elements, ...).

Definition at line 376 of file genericfileelement.h.

◆ makeBuffer()

template<class ImplementationType >
void TagParser::GenericFileElement< ImplementationType >::makeBuffer ( )

Buffers the element (header and data).

Remarks
The element must have been parsed.

Definition at line 886 of file genericfileelement.h.

◆ maximumIdLengthSupported()

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::maximumIdLengthSupported ( )
staticconstexpr

Returns the maximum id length supported by the class in byte.

Definition at line 980 of file genericfileelement.h.

◆ maximumSizeLengthSupported()

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::maximumSizeLengthSupported ( )
staticconstexpr

Returns the maximum size length supported by the class in byte.

Definition at line 988 of file genericfileelement.h.

◆ maxTotalSize()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::maxTotalSize ( ) const
inline

Returns maximum total size.

This is usually the size of the file for top-level elements and the remaining size of the parent for non-top-level elements.

Definition at line 367 of file genericfileelement.h.

◆ minimumElementSize()

template<class ImplementationType >
std::uint8_t TagParser::GenericFileElement< ImplementationType >::minimumElementSize ( )
staticconstexpr

Returns the minimum element size.

Definition at line 996 of file genericfileelement.h.

◆ nextSibling() [1/2]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::nextSibling ( )
inline

Returns the next sibling of the element.

The current element keeps ownership over the returned element. If no next sibling is present nullptr is returned.

Remarks
parse() needs to be called before.

Definition at line 439 of file genericfileelement.h.

◆ nextSibling() [2/2]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::nextSibling ( ) const
inline

Returns the next sibling of the element.

The current element keeps ownership over the returned element. If no next sibling is present nullptr is returned.

Remarks
parse() needs to be called before.

Definition at line 452 of file genericfileelement.h.

◆ operator=()

template<class ImplementationType >
GenericFileElement & TagParser::GenericFileElement< ImplementationType >::operator= ( const GenericFileElement< ImplementationType > & other)
delete

◆ parent() [1/4]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::parent ( )
inline

Returns the parent of the element.

The returned element has ownership over the current instance. If the current element is a top level element nullptr is returned.

Definition at line 390 of file genericfileelement.h.

◆ parent() [2/4]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::parent ( ) const
inline

Returns the parent of the element.

The returned element has ownership over the current instance. If the current element is a top level element nullptr is returned.

Definition at line 401 of file genericfileelement.h.

◆ parent() [3/4]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::parent ( std::uint8_t n)

Returns the n-th parent of the element.

Remarks
  • The returned element has ownership (at least indirect) over the current instance.
  • Returns nullptr if level() < n.

Definition at line 412 of file genericfileelement.h.

◆ parent() [4/4]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::parent ( std::uint8_t n) const
inline

Returns the n-th parent of the element.

Remarks
  • The returned element has ownership (at least indirect) over the current instance.
  • Returns nullptr if level() < n.

Definition at line 426 of file genericfileelement.h.

◆ parse()

template<class ImplementationType >
void TagParser::GenericFileElement< ImplementationType >::parse ( Diagnostics & diag)

Parses the header information of the element which is read from the related stream at the start offset.

The parsed information can accessed using the corresponding methods such as id() for the element id and totalSize() for the element size.

If the element has already been parsed (isParsed() returns true) this method does nothing. To force reparsing call reparse().

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsTagParser::Failure or a derived exception when a parsing error occurs.

Definition at line 779 of file genericfileelement.h.

◆ reader()

template<class ImplementationType >
CppUtilities::BinaryReader & TagParser::GenericFileElement< ImplementationType >::reader ( )
inline

Returns the related BinaryReader.

Definition at line 250 of file genericfileelement.h.

◆ relativeStartOffset()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::relativeStartOffset ( ) const
inline

Returns the offset of the element in its parent or - if it is a top-level element - in the related stream.

Definition at line 274 of file genericfileelement.h.

◆ reparse()

template<class ImplementationType >
void TagParser::GenericFileElement< ImplementationType >::reparse ( Diagnostics & diag)

Parses the header information of the element which is read from the related stream at the start offset.

The parsed information can accessed using the corresponding methods such as id() for the element id and totalSize() for the element size.

If the element has already been parsed (isParsed() returns true) this method clears the parsed information and reparses the header.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsTagParser::Failure or a derived exception when a parsing error occurs.
See also
parse()

Definition at line 803 of file genericfileelement.h.

◆ siblingById() [1/2]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::siblingById ( const IdentifierType & id,
Diagnostics & diag )

Returns the first sibling with the specified id.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned. Possibly returns a pointer to the current instance (see includeThis).

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 648 of file genericfileelement.h.

◆ siblingById() [2/2]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::siblingById ( const IdentifierType & id,
Diagnostics & diag ) const

Returns the first sibling with the specified id.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned. Possibly returns a pointer to the current instance (see includeThis).

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 671 of file genericfileelement.h.

◆ siblingByIdIncludingThis() [1/2]

template<class ImplementationType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::siblingByIdIncludingThis ( const IdentifierType & id,
Diagnostics & diag )

Returns the first sibling with the specified id or the current instance if its ID equals id.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned. Possibly returns a pointer to the current instance (see includeThis).

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 687 of file genericfileelement.h.

◆ siblingByIdIncludingThis() [2/2]

template<class ImplementationType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::siblingByIdIncludingThis ( const IdentifierType & id,
Diagnostics & diag ) const

Returns the first sibling with the specified id or the current instance if its ID equals id.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned. Possibly returns a pointer to the current instance (see includeThis).

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 710 of file genericfileelement.h.

◆ sizeLength()

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::sizeLength ( ) const
inline

Returns the length of the size denotation of the element in byte.

Definition at line 328 of file genericfileelement.h.

◆ startOffset()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::startOffset ( ) const
inline

Returns the start offset in the related stream.

Definition at line 266 of file genericfileelement.h.

◆ stream()

template<class ImplementationType >
std::iostream & TagParser::GenericFileElement< ImplementationType >::stream ( )
inline

Returns the related stream.

Definition at line 242 of file genericfileelement.h.

◆ subelementByPath() [1/4]

template<class ImplementationType >
template<class IdType >
ImplementationType * TagParser::GenericFileElement< ImplementationType >::subelementByPath ( Diagnostics & diag,
IdType item )

Returns the sub element for the specified path.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned.

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 525 of file genericfileelement.h.

◆ subelementByPath() [2/4]

template<class ImplementationType >
template<class IdType >
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::subelementByPath ( Diagnostics & diag,
IdType item ) const

Returns the sub element for the specified path.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned.

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 580 of file genericfileelement.h.

◆ subelementByPath() [3/4]

template<class ImplementationType >
template<class IdType , class... IdTypes>
ImplementationType * TagParser::GenericFileElement< ImplementationType >::subelementByPath ( Diagnostics & diag,
IdType item,
IdTypes... remainingPath )

Returns the sub element for the specified path.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned.

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 551 of file genericfileelement.h.

◆ subelementByPath() [4/4]

template<class ImplementationType >
template<class IdType , class... IdTypes>
const ImplementationType * TagParser::GenericFileElement< ImplementationType >::subelementByPath ( Diagnostics & diag,
IdType item,
IdTypes... remainingPath ) const

Returns the sub element for the specified path.

The current element keeps ownership over the returned element. If no element could be found nullptr is returned.

Exceptions
Throwsa parsing exception when a parsing error occurs.
Throwsstd::ios_base::failure when an IO error occurs.

Definition at line 596 of file genericfileelement.h.

◆ totalSize()

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::totalSize ( ) const
inline

Returns the total size of the element.

This is the sum of the header size and the data size.

Definition at line 348 of file genericfileelement.h.

◆ validateSubsequentElementStructure()

template<class ImplementationType >
void TagParser::GenericFileElement< ImplementationType >::validateSubsequentElementStructure ( Diagnostics & diag,
std::uint64_t * paddingSize = nullptr,
AbortableProgressFeedback * progress = nullptr )

Parses (see parse()) this and all subsequent elements.

All diagnostic message will be stored in diag. If padding is found its size will be set to paddingSize if not nullptr.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsTagParser::Failure or a derived exception when a parsing error occurs.
See also
parse()

Definition at line 823 of file genericfileelement.h.

◆ writer()

template<class ImplementationType >
CppUtilities::BinaryWriter & TagParser::GenericFileElement< ImplementationType >::writer ( )
inline

Returns the related BinaryWriter.

Definition at line 258 of file genericfileelement.h.

Friends And Related Symbol Documentation

◆ FileElementTraits< ImplementationType >

template<class ImplementationType >
friend class FileElementTraits< ImplementationType >
friend

Definition at line 996 of file genericfileelement.h.

Member Data Documentation

◆ m_buffer

template<class ImplementationType >
std::unique_ptr<char[]> TagParser::GenericFileElement< ImplementationType >::m_buffer
protected

Definition at line 144 of file genericfileelement.h.

◆ m_dataSize

template<class ImplementationType >
DataSizeType TagParser::GenericFileElement< ImplementationType >::m_dataSize
protected

Definition at line 138 of file genericfileelement.h.

◆ m_firstChild

template<class ImplementationType >
std::unique_ptr<ImplementationType> TagParser::GenericFileElement< ImplementationType >::m_firstChild
protected

Definition at line 143 of file genericfileelement.h.

◆ m_id

template<class ImplementationType >
IdentifierType TagParser::GenericFileElement< ImplementationType >::m_id
protected

Definition at line 135 of file genericfileelement.h.

◆ m_idLength

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::m_idLength
protected

Definition at line 139 of file genericfileelement.h.

◆ m_maxSize

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::m_maxSize
protected

Definition at line 137 of file genericfileelement.h.

◆ m_nextSibling

template<class ImplementationType >
std::unique_ptr<ImplementationType> TagParser::GenericFileElement< ImplementationType >::m_nextSibling
protected

Definition at line 142 of file genericfileelement.h.

◆ m_parent

template<class ImplementationType >
ImplementationType* TagParser::GenericFileElement< ImplementationType >::m_parent
protected

Definition at line 141 of file genericfileelement.h.

◆ m_sizeLength

template<class ImplementationType >
std::uint32_t TagParser::GenericFileElement< ImplementationType >::m_sizeLength
protected

Definition at line 140 of file genericfileelement.h.

◆ m_sizeUnknown

template<class ImplementationType >
bool TagParser::GenericFileElement< ImplementationType >::m_sizeUnknown
protected

Definition at line 155 of file genericfileelement.h.

◆ m_startOffset

template<class ImplementationType >
std::uint64_t TagParser::GenericFileElement< ImplementationType >::m_startOffset
protected

Definition at line 136 of file genericfileelement.h.


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