From c8973c742cc7deaade63e15ef01ccf4cffbe2f8d Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 17 Jun 2019 19:11:20 +0200 Subject: [PATCH] Remove unused functions of MatroskaSeekInfo --- matroska/matroskaseekinfo.cpp | 73 +++-------------------------------- matroska/matroskaseekinfo.h | 8 +--- 2 files changed, 7 insertions(+), 74 deletions(-) diff --git a/matroska/matroskaseekinfo.cpp b/matroska/matroskaseekinfo.cpp index e9602df..f707403 100644 --- a/matroska/matroskaseekinfo.cpp +++ b/matroska/matroskaseekinfo.cpp @@ -44,11 +44,11 @@ void MatroskaSeekInfo::shift(std::uint64_t start, std::int64_t amount) * - Possibly previously parsed info() is not cleared. So subsequent calls can be used to gather seek * information from multiple seek head elements. Use clear() manually if that is not wanted. * - If the specified \a seekHeadElement references another seek head element the referenced seek head - * element is parsed as well. One can set \a maxNesting to 0 to prevent that or even increase the value + * element is parsed as well. One can set \a maxIndirection to 0 to prevent that or even increase the value * to allow following references even more deeply. References to elements which have already been visited * are never followed, though. */ -void MatroskaSeekInfo::parse(EbmlElement *seekHeadElement, Diagnostics &diag, size_t maxNesting) +void MatroskaSeekInfo::parse(EbmlElement *seekHeadElement, Diagnostics &diag, size_t maxIndirection) { static const string context("parsing \"SeekHead\"-element"); @@ -97,7 +97,7 @@ void MatroskaSeekInfo::parse(EbmlElement *seekHeadElement, Diagnostics &diag, si // follow possibly referenced seek head element if (m_info.back().first == MatroskaIds::SeekHead) { const auto startOffset = m_info.back().second; - if (!maxNesting) { + if (!maxIndirection) { diag.emplace_back(DiagLevel::Warning, argsToString("Not following reference by \"Seek\" element at ", seekElement->startOffset(), " contains to another \"SeekHead\" element at ", startOffset, '.'), context); @@ -118,7 +118,7 @@ void MatroskaSeekInfo::parse(EbmlElement *seekHeadElement, Diagnostics &diag, si break; } m_additionalSeekHeadElements.emplace_back(make_unique(seekHeadElement->container(), startOffset)); - parse(m_additionalSeekHeadElements.back().get(), diag, maxNesting - 1); + parse(m_additionalSeekHeadElements.back().get(), diag, maxIndirection - 1); } break; @@ -246,70 +246,9 @@ bool MatroskaSeekInfo::push(unsigned int index, EbmlElement::IdentifierType id, */ void MatroskaSeekInfo::clear() { - m_seekHeadElement = nullptr; + m_seekHeadElements.clear(); + m_additionalSeekHeadElements.clear(); m_info.clear(); } -/*! - * \brief Returns a pointer to the first pair with the specified \a offset or nullptr if no such pair could be found. - */ -std::pair *MatroskaSeekInfo::findSeekInfo(std::vector &seekInfos, std::uint64_t offset) -{ - for (auto &seekInfo : seekInfos) { - for (auto &entry : seekInfo.info()) { - if (get<1>(entry) == offset) { - return &entry; - } - } - } - return nullptr; -} - -/*! - * \brief Sets the offset of all entires in \a newSeekInfos to \a newOffset where the corresponding entry in \a oldSeekInfos has the offset \a oldOffset. - * \returns Returns an indication whether the update altered the offset length. - */ -bool MatroskaSeekInfo::updateSeekInfo( - const std::vector &oldSeekInfos, std::vector &newSeekInfos, std::uint64_t oldOffset, std::uint64_t newOffset) -{ - bool updated = false; - auto oldIterator0 = oldSeekInfos.cbegin(), oldEnd0 = oldSeekInfos.cend(); - auto newIterator0 = newSeekInfos.begin(), newEnd0 = newSeekInfos.end(); - for (; oldIterator0 != oldEnd0 && newIterator0 != newEnd0; ++oldIterator0, ++newIterator0) { - auto oldIterator1 = oldIterator0->info().cbegin(), oldEnd1 = oldIterator0->info().cend(); - auto newIterator1 = newIterator0->info().begin(), newEnd1 = newIterator0->info().end(); - for (; oldIterator1 != oldEnd1 && newIterator1 != newEnd1; ++oldIterator1, ++newIterator1) { - if (get<1>(*oldIterator1) == oldOffset) { - if (get<1>(*newIterator1) != newOffset) { - updated - = updated || (EbmlElement::calculateUIntegerLength(newOffset) != EbmlElement::calculateUIntegerLength(get<1>(*newIterator1))); - get<1>(*newIterator1) = newOffset; - } - } - } - } - return updated; -} - -/*! - * \brief Sets the offset of all entires in \a newSeekInfos to \a newOffset where the offset is \a oldOffset. - * \returns Returns an whether at least one offset has been updated. - */ -bool MatroskaSeekInfo::updateSeekInfo(std::vector &newSeekInfos, std::uint64_t oldOffset, std::uint64_t newOffset) -{ - if (oldOffset == newOffset) { - return false; - } - bool updated = false; - for (auto &seekInfo : newSeekInfos) { - for (auto &info : seekInfo.info()) { - if (get<1>(info) == oldOffset) { - get<1>(info) = newOffset; - updated = true; - } - } - } - return updated; -} - } // namespace TagParser diff --git a/matroska/matroskaseekinfo.h b/matroska/matroskaseekinfo.h index 6cef8ac..3f33f95 100644 --- a/matroska/matroskaseekinfo.h +++ b/matroska/matroskaseekinfo.h @@ -15,7 +15,7 @@ public: const std::vector> &info() const; std::vector> &info(); void shift(std::uint64_t start, std::int64_t amount); - void parse(EbmlElement *seekHeadElements, Diagnostics &diag, std::size_t maxNesting = 1); + void parse(EbmlElement *seekHeadElements, Diagnostics &diag, std::size_t maxIndirection = 1); void make(std::ostream &stream, Diagnostics &diag); std::uint64_t minSize() const; std::uint64_t maxSize() const; @@ -23,12 +23,6 @@ public: bool push(unsigned int index, EbmlElement::IdentifierType id, std::uint64_t offset); void clear(); - // these methods seem to be not needed anymore - static std::pair *findSeekInfo(std::vector &seekInfos, std::uint64_t offset); - static bool updateSeekInfo(const std::vector &oldSeekInfos, std::vector &newSeekInfos, - std::uint64_t oldOffset, std::uint64_t newOffset); - static bool updateSeekInfo(std::vector &newSeekInfos, std::uint64_t oldOffset, std::uint64_t newOffset); - private: std::vector m_seekHeadElements; std::vector> m_additionalSeekHeadElements;