Add method to determine level of file element

This commit is contained in:
Martchus 2017-08-18 00:07:11 +02:00
parent 99227816b6
commit 90dccb2bd9
1 changed files with 13 additions and 0 deletions

View File

@ -157,6 +157,7 @@ public:
uint64 totalSize() const;
uint64 endOffset() const;
uint64 maxTotalSize() const;
byte level() const;
ImplementationType* parent();
const ImplementationType* parent() const;
ImplementationType* nextSibling();
@ -436,6 +437,18 @@ inline uint64 GenericFileElement<ImplementationType>::maxTotalSize() const
return m_maxSize;
}
/*!
* \brief Returns how deep the element is nested (0 for top-level elements, 1 for children of
* top-level elements, ...).
*/
template<class ImplementationType>
byte GenericFileElement<ImplementationType>::level() const
{
byte level = 0;
for(const ImplementationType *parent = m_parent; parent; ++level, parent = parent->m_parent);
return level;
}
/*!
* \brief Returns the parent of the element.
*