From 8141e3c83db963cf1f9825510c8358cc1910ce17 Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Thu, 10 Apr 2025 15:19:12 +0200 Subject: [PATCH] Add option to skip toggle or to take only toggle Signed-off-by: Ryszard Rozak --- src/VlcMain.cpp | 2 ++ src/VlcOptions.h | 4 ++++ src/VlcPoint.h | 1 + src/VlcTop.cpp | 5 +++++ 4 files changed, 12 insertions(+) diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index fbabc9b07..e39e90472 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -80,6 +80,8 @@ void VlcOptions::parseOptsList(int argc, char** argv) { }); DECL_OPTION("-write", Set, &m_writeFile); DECL_OPTION("-write-info", Set, &m_writeInfoFile); + DECL_OPTION("-toggle-only", OnOff, &m_toggleOnly); + DECL_OPTION("-skip-toggle", OnOff, &m_skipToggle); parser.finalize(); // Parse parameters diff --git a/src/VlcOptions.h b/src/VlcOptions.h index edd889957..26c48f35a 100644 --- a/src/VlcOptions.h +++ b/src/VlcOptions.h @@ -43,6 +43,8 @@ class VlcOptions final { bool m_unlink = false; // main switch: --unlink string m_writeFile; // main switch: --write string m_writeInfoFile; // main switch: --write-info + bool m_toggleOnly = false; // main switch: --m_toggle_only + bool m_skipToggle = false; // main switch: --m_skip_toggle // clang-format on private: @@ -69,6 +71,8 @@ public: bool unlink() const { return m_unlink; } string writeFile() const { return m_writeFile; } string writeInfoFile() const { return m_writeInfoFile; } + bool toggleOnly() const { return m_toggleOnly; } + bool skipToggle() const { return m_skipToggle; } // METHODS (from main) static string version() VL_MT_DISABLED; diff --git a/src/VlcPoint.h b/src/VlcPoint.h index 62d92871f..6660a2acc 100644 --- a/src/VlcPoint.h +++ b/src/VlcPoint.h @@ -73,6 +73,7 @@ public: int lineno() const { return std::atoi(keyExtract(VL_CIK_LINENO, m_name.c_str()).c_str()); } int column() const { return std::atoi(keyExtract(VL_CIK_COLUMN, m_name.c_str()).c_str()); } // METHODS + static bool isToggle(const char* name) { return keyExtract(VL_CIK_TYPE, name) == "toggle"; } static string keyExtract(const char* shortKey, const char* name) { // Hot function const size_t shortLen = std::strlen(shortKey); diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index e16edfab3..7332cd957 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -51,6 +51,11 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) { if (line[secspace] == '\'' && line[secspace + 1] == ' ') break; } const string point = line.substr(3, secspace - 3); + if (opt.skipToggle() && VlcPoint::isToggle(point.c_str())) { + continue; + } else if (opt.toggleOnly() && !VlcPoint::isToggle(point.c_str())) { + continue; + } const uint64_t hits = std::atoll(line.c_str() + secspace + 1); // UINFO(9," point '"<