LCOV - code coverage report
Current view: top level - src/notation/internal - searchcommandsparser.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 34 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #pragma once
      24              : 
      25              : #include "types/string.h"
      26              : 
      27              : namespace mu::notation {
      28              : class SearchCommandsParser
      29              : {
      30              : public:
      31              :     struct SearchData
      32              :     {
      33              :         enum class Type : unsigned char {
      34              :             Invalid,
      35              :             RehearsalMark,
      36              :             Measure,
      37              :             MeasureRange,
      38              :             Page
      39              :         };
      40              : 
      41              :         Type type = Type::Invalid;
      42              :         std::variant<std::monostate, muse::String, size_t, std::pair<size_t, size_t> > value;
      43              : 
      44            0 :         bool isValid() const
      45              :         {
      46            0 :             return type != Type::Invalid;
      47              :         }
      48              : 
      49            0 :         static SearchData makeRehearsalMark(const muse::String& name)
      50              :         {
      51            0 :             SearchData data;
      52            0 :             data.type = Type::RehearsalMark;
      53            0 :             data.value = name;
      54            0 :             return data;
      55              :         }
      56              : 
      57            0 :         muse::String rehearsalMark() const
      58              :         {
      59            0 :             assert(type == Type::RehearsalMark);
      60            0 :             return std::get<muse::String>(value);
      61              :         }
      62              : 
      63            0 :         static SearchData makeMeasure(size_t index)
      64              :         {
      65            0 :             SearchData data;
      66            0 :             data.type = Type::Measure;
      67            0 :             data.value = index;
      68            0 :             return data;
      69              :         }
      70              : 
      71            0 :         int measureIndex() const
      72              :         {
      73            0 :             assert(type == Type::Measure);
      74            0 :             return static_cast<int>(std::get<size_t>(value));
      75              :         }
      76              : 
      77            0 :         static SearchData makeMeasureRange(size_t startIndex, size_t endIndex)
      78              :         {
      79            0 :             SearchData data;
      80            0 :             data.type = Type::MeasureRange;
      81            0 :             data.value = std::make_pair(startIndex, endIndex);
      82            0 :             return data;
      83              :         }
      84              : 
      85            0 :         std::pair<size_t, size_t> measureRange() const
      86              :         {
      87            0 :             assert(type == Type::MeasureRange);
      88            0 :             return std::get<std::pair<size_t, size_t> >(value);
      89              :         }
      90              : 
      91            0 :         static SearchData makePage(size_t index)
      92              :         {
      93            0 :             SearchData data;
      94            0 :             data.type = Type::Page;
      95            0 :             data.value = index;
      96            0 :             return data;
      97              :         }
      98              : 
      99            0 :         size_t pageIndex() const
     100              :         {
     101            0 :             assert(type == Type::Page);
     102            0 :             return std::get<size_t>(value);
     103              :         }
     104              :     };
     105              : 
     106              :     static SearchData parse(const QString& searchCommand);
     107              : 
     108              : private:
     109              :     static SearchData parseMeasureCommand(const QString& searchCommand);
     110              :     static SearchData parsePageCommand(const QString& searchCommand);
     111              :     static SearchData parseRehearsalMarkCommand(const QString& searchCommand);
     112              : };
     113              : }
        

Generated by: LCOV version 2.0-1