diff --git a/genericfileelement.h b/genericfileelement.h index 1d85e51..52123e1 100644 --- a/genericfileelement.h +++ b/genericfileelement.h @@ -189,6 +189,7 @@ public: void copyHeader(std::ostream &targetStream); void copyWithoutChilds(std::ostream &targetStream); void copyEntirely(std::ostream &targetStream); + implementationType *denoteFirstChild(uint32 offset); protected: identifierType m_id; @@ -825,6 +826,21 @@ void GenericFileElement::copyInternal(std::ostream &targetSt } } +/*! + * \brief Denotes the first child to start at the specified \a offset (relative to the start offset of this descriptor). + * \remarks A new first child is constructed. A possibly existing subtree is invalidated. + */ +template +typename GenericFileElement::implementationType *GenericFileElement::denoteFirstChild(uint32 relativeFirstChildOffset) +{ + if(relativeFirstChildOffset + 4 < dataSize()) { + m_firstChild.reset(new implementationType(static_cast(*this), startOffset() + relativeFirstChildOffset)); + } else { + m_firstChild.reset(); + } + return m_firstChild.get(); +} + /*! * \brief Returns the maximum id length supported by the class in byte. */