LCOV - code coverage report
Current view: top level - jdx - LdrContainer.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 16 16 100.0 %
Date: 2025-06-15 16:18:27 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* Copyright (C) 2025 Robert Schiwon
       2             :  *
       3             :  * This file is part of libjdx.
       4             :  *
       5             :  * libjdx is free software: you can redistribute it and/or modify it under the
       6             :  * terms of the GNU Lesser General Public License as published by the Free
       7             :  * Software Foundation, either version 3 of the License, or (at your option) any
       8             :  * later version.
       9             :  *
      10             :  * libjdx is distributed in the hope that it will be useful, but WITHOUT ANY
      11             :  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      12             :  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with libjdx. If not, see <https://www.gnu.org/licenses/>.
      17             :  */
      18             : #include "jdx/LdrContainer.hpp"
      19             : #include "util/LdrUtils.hpp"
      20             : #include "util/StringUtils.hpp"
      21             : 
      22        1579 : std::optional<const std::string> libjdx::jdx::LdrContainer::parseStringValue(
      23             :     std::string& value, io::TextReader& reader)
      24             : {
      25        1579 :     util::trim(value); // trim first line value only
      26        1602 :     while (!reader.eof())
      27             :     {
      28        1599 :         auto line = reader.readLine();
      29        1599 :         if (util::isLdrStart(line))
      30             :         {
      31        1556 :             return line;
      32             :         }
      33          43 :         auto [content, comment] = util::stripLineComment(line);
      34          43 :         if (!content.empty() && !value.empty() && value.back() == '=')
      35             :         {
      36             :             // account for terminal "=" as non line breaking marker
      37           2 :             value.pop_back();
      38           2 :             value.append(line);
      39             :         }
      40             :         // Bruker quirk: check for specific comments that indicate the end of
      41             :         // the previous LDR
      42          63 :         else if (content.empty() && comment.has_value()
      43          75 :                  && (util::isBrukerSpecificSectionStart(line)
      44          12 :                      || util::isBrukerSpecificSectionEnd(line)))
      45             :         {
      46          20 :             return line;
      47             :         }
      48             :         else
      49             :         {
      50          21 :             value.append('\n' + line);
      51             :         }
      52             :     }
      53           3 :     return std::nullopt;
      54             : }

Generated by: LCOV version 1.14