added method to manually denote the offset of the first child

This commit is contained in:
Martchus 2015-07-07 02:58:29 +02:00
parent 7da37e888d
commit 3332423fca
1 changed files with 16 additions and 0 deletions

View File

@ -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<ImplementationType>::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 <class ImplementationType>
typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::denoteFirstChild(uint32 relativeFirstChildOffset)
{
if(relativeFirstChildOffset + 4 < dataSize()) {
m_firstChild.reset(new implementationType(static_cast<implementationType &>(*this), startOffset() + relativeFirstChildOffset));
} else {
m_firstChild.reset();
}
return m_firstChild.get();
}
/*!
* \brief Returns the maximum id length supported by the class in byte.
*/