LCOV - code coverage report
Current view: top level - src/engraving/rw - harmonytodiagramreader.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 85.7 % 28 24
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) 2025 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              : #include "harmonytodiagramreader.h"
      23              : 
      24              : using namespace mu::engraving::rw;
      25              : 
      26            2 : std::unordered_map<muse::String, HarmonyToDiagramReader::FretDiagramInfo> HarmonyToDiagramReader::read(XmlReader& reader)
      27              : {
      28            2 :     std::unordered_map<String, HarmonyToDiagramReader::FretDiagramInfo> result;
      29              : 
      30            4 :     while (reader.readNextStartElement()) {
      31            2 :         if (reader.name() != "Data") {
      32            0 :             break;
      33              :         }
      34              : 
      35         6250 :         while (reader.readNextStartElement()) {
      36         6248 :             if (reader.name() == "HarmonyToDiagram") {
      37         6248 :                 String harmony;
      38         6248 :                 String diagram;
      39         6248 :                 String pattern;
      40        24992 :                 while (reader.readNextStartElement()) {
      41        18744 :                     if (reader.name() == "Harmony") {
      42        12496 :                         while (reader.readNextStartElement()) {
      43         6248 :                             if (reader.name() == "name") {
      44         6248 :                                 harmony = reader.readText();
      45              :                             } else {
      46            0 :                                 reader.unknown();
      47              :                             }
      48              :                         }
      49        12496 :                     } else if (reader.name() == "FretDiagram") {
      50         6248 :                         diagram = reader.readBody();
      51         6248 :                         reader.skipCurrentElement();
      52         6248 :                     } else if (reader.name() == "pattern") {
      53         6248 :                         pattern = reader.readText();
      54              :                     } else {
      55            0 :                         reader.unknown();
      56              :                     }
      57              :                 }
      58              : 
      59         6248 :                 if (!harmony.isEmpty() && !diagram.isEmpty()) {
      60        12496 :                     result.insert({ std::move(harmony), { std::move(diagram), std::move(pattern) } });
      61              :                 }
      62         6248 :             } else {
      63            0 :                 reader.unknown();
      64              :             }
      65              :         }
      66              :     }
      67              : 
      68            2 :     return result;
      69         6248 : }
        

Generated by: LCOV version 2.0-1