LCOV - code coverage report
Current view: top level - src/importexport/guitarpro/internal - importgtp-gp7.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 86.2 % 29 25
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              : #include "importgtp.h"
      23              : 
      24              : #include "serialization/zipreader.h"
      25              : 
      26              : #include "gtp/gp7dombuilder.h"
      27              : #include "engraving/dom/factory.h"
      28              : #include "engraving/dom/bracketitem.h"
      29              : #include "engraving/dom/instrtemplate.h"
      30              : #include "engraving/dom/masterscore.h"
      31              : #include "engraving/dom/part.h"
      32              : #include "engraving/dom/staff.h"
      33              : #include "engraving/dom/stringtunings.h"
      34              : 
      35              : #include "log.h"
      36              : 
      37              : using namespace muse;
      38              : using namespace muse::io;
      39              : using namespace mu::engraving;
      40              : 
      41              : namespace mu::iex::guitarpro {
      42              : //---------------------------------------------------------
      43              : //   read
      44              : //---------------------------------------------------------
      45              : 
      46          145 : bool GuitarPro7::read(IODevice* io)
      47              : {
      48          145 :     f = io;
      49          145 :     previousTempo = -1;
      50              : 
      51          145 :     ZipReader zip(io);
      52          290 :     ByteArray fileData = zip.fileData("Content/score.gpif");
      53          145 :     ByteArray partsData = zip.fileData("Content/PartConfiguration");
      54          145 :     zip.close();
      55              : 
      56          145 :     m_properties = readProperties(&partsData);
      57              : 
      58          145 :     readGpif(&fileData);
      59          145 :     return true;
      60          145 : }
      61              : 
      62              : //---------------------------------------------------------
      63              : //   readProperties
      64              : //---------------------------------------------------------
      65              : 
      66          145 : GuitarPro::GPProperties GuitarPro7::readProperties(ByteArray* data)
      67              : {
      68          145 :     GPProperties properties;
      69          145 :     size_t partsInfoSize = data->size();
      70          145 :     const size_t numInstrOffset = 8;
      71          145 :     if (partsInfoSize <= numInstrOffset) {
      72            0 :         LOGE() << "failed to read gp properties";
      73            0 :         return properties;
      74              :     }
      75              : 
      76          145 :     size_t numberOfInstruments = static_cast<size_t>(data->at(numInstrOffset));
      77          145 :     if (partsInfoSize <= numInstrOffset + numberOfInstruments) {
      78            0 :         LOGE() << "failed to read gp properties";
      79            0 :         return properties;
      80              :     }
      81              : 
      82          145 :     std::vector<TabImportOption> partsImportOpts = properties.partsImportOptions;
      83              : 
      84          302 :     for (size_t i = numInstrOffset + 1; i <= numInstrOffset + numberOfInstruments; i++) {
      85          157 :         partsImportOpts.push_back(static_cast<TabImportOption>(data->at(static_cast<int>(i))));
      86              :     }
      87              : 
      88          145 :     return properties;
      89          145 : }
      90              : 
      91          145 : std::unique_ptr<IGPDomBuilder> GuitarPro7::createGPDomBuilder() const
      92              : {
      93          145 :     return std::make_unique<GP7DomBuilder>();
      94              : }
      95              : } // namespace mu::iex::guitarpro
        

Generated by: LCOV version 2.0-1