LCOV - code coverage report
Current view: top level - src/importexport/mei/internal - meireader.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 87.0 % 23 20
Test Date: 2026-11-19 04:14:36

            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              : #include "meireader.h"
      24              : 
      25              : #include "engraving/engravingerrors.h"
      26              : #include "engraving/dom/masterscore.h"
      27              : 
      28              : #include "meiimporter.h"
      29              : #include "meiconverter.h"
      30              : 
      31              : using namespace muse;
      32              : using namespace mu::iex::mei;
      33              : using namespace mu::engraving;
      34              : 
      35            2 : Ret MeiReader::read(MasterScore* score, const muse::io::path_t& path, const Options& options)
      36              : {
      37            2 :     Err result = this->import(score, path, options);
      38            2 :     if (result == Err::NoError) {
      39            1 :         return muse::make_ok();
      40              :     }
      41              : 
      42            1 :     if (result == Err::FileCorrupted) {
      43            1 :         return make_ret(result, Convert::logs.join(u"\n"));
      44              :     }
      45              : 
      46            0 :     return make_ret(result, path);
      47              : }
      48              : 
      49           66 : Err MeiReader::import(MasterScore* score, const muse::io::path_t& path, const Options& options)
      50              : {
      51           66 :     if (!fileSystem()->exists(path)) {
      52            0 :         return Err::FileNotFound;
      53              :     }
      54              : 
      55           66 :     MeiImporter importer(score);
      56           66 :     if (!importer.read(path)) {
      57            0 :         return Err::FileCriticallyCorrupted;
      58              :     }
      59              : 
      60           66 :     bool forceMode = false;
      61           66 :     if (options.count(INotationReader::OptionKey::ForceMode)) {
      62            2 :         Val val = options.at(INotationReader::OptionKey::ForceMode);
      63            2 :         forceMode = (!val.isNull() && val.toBool());
      64            2 :     }
      65              : 
      66           66 :     bool hasWarnings = (Convert::logs.size() > 0);
      67              : 
      68              :     //! NOTE The user decides whether to load the file anyway, then it is loaded again in the force mode
      69           66 :     if (!forceMode && !MScore::noGui && hasWarnings) {
      70            1 :         return Err::FileCorrupted;
      71              :     }
      72              : 
      73           65 :     return Err::NoError;
      74           66 : }
        

Generated by: LCOV version 2.0-1