differential code coverage report with master
Current view: top level - source/workbook - named_range.cpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 52.4 % 21 11 10 11
Current Date: 2025-12-15 23:01:28 Functions: 50.0 % 8 4 4 4
Baseline: coverage_master.info Branches: 16.7 % 6 1 10 2
Baseline Date: 2025-12-15 23:01:27

             Branch data    TLA  Line data    Source code
       1                 :                : // Copyright (c) 2014-2022 Thomas Fussell
       2                 :                : // Copyright (c) 2010-2015 openpyxl
       3                 :                : // Copyright (c) 2024-2025 xlnt-community
       4                 :                : //
       5                 :                : // Permission is hereby granted, free of charge, to any person obtaining a copy
       6                 :                : // of this software and associated documentation files (the "Software"), to deal
       7                 :                : // in the Software without restriction, including without limitation the rights
       8                 :                : // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       9                 :                : // copies of the Software, and to permit persons to whom the Software is
      10                 :                : // furnished to do so, subject to the following conditions:
      11                 :                : //
      12                 :                : // The above copyright notice and this permission notice shall be included in
      13                 :                : // all copies or substantial portions of the Software.
      14                 :                : //
      15                 :                : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16                 :                : // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17                 :                : // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      18                 :                : // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19                 :                : // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      20                 :                : // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      21                 :                : // THE SOFTWARE
      22                 :                : //
      23                 :                : // @license: http://www.opensource.org/licenses/mit-license.php
      24                 :                : // @author: see AUTHORS file
      25                 :                : #include <xlnt/utils/exceptions.hpp>
      26                 :                : #include <xlnt/workbook/named_range.hpp>
      27                 :                : #include <xlnt/worksheet/range_reference.hpp>
      28                 :                : #include <xlnt/worksheet/worksheet.hpp>
      29                 :                : 
      30                 :                : namespace {
      31                 :                : 
      32                 :                : /// <summary>
      33                 :                : /// Return a vector containing string split at each delim.
      34                 :                : /// </summary>
      35                 :                : /// <remark>
      36                 :                : /// This should maybe be in a utility header so it can be used elsewhere.
      37                 :                : /// </remarks>
      38                 :                : /*
      39                 :                : std::vector<std::string> split_string(const std::string &string, char delim)
      40                 :                : {
      41                 :                :     std::vector<std::string> split;
      42                 :                :     std::string::size_type previous_index = 0;
      43                 :                :     auto separator_index = string.find(delim);
      44                 :                : 
      45                 :                :     while (separator_index != std::string::npos)
      46                 :                :     {
      47                 :                :         auto part = string.substr(previous_index, separator_index - previous_index);
      48                 :                :         split.push_back(part);
      49                 :                : 
      50                 :                :         previous_index = separator_index + 1;
      51                 :                :         separator_index = string.find(delim, previous_index);
      52                 :                :     }
      53                 :                : 
      54                 :                :     split.push_back(string.substr(previous_index));
      55                 :                : 
      56                 :                :     return split;
      57                 :                : }
      58                 :                : */
      59                 :                : 
      60                 :                : /*
      61                 :                : std::vector<std::pair<std::string, std::string>> split_named_range(const std::string &named_range_string)
      62                 :                : {
      63                 :                :     std::vector<std::pair<std::string, std::string>> result;
      64                 :                : 
      65                 :                :     for (auto part : split_string(named_range_string, ','))
      66                 :                :     {
      67                 :                :         auto split = split_string(part, '!');
      68                 :                : 
      69                 :                :         if (split[0].front() == '\'' && split[0].back() == '\'')
      70                 :                :         {
      71                 :                :             split[0] = split[0].substr(1, split[0].length() - 2);
      72                 :                :         }
      73                 :                : 
      74                 :                :         // Try to parse it. Use empty string if it's not a valid range.
      75                 :                :         try
      76                 :                :         {
      77                 :                :             xlnt::range_reference ref(split[1]);
      78                 :                :         }
      79                 :                :         catch (xlnt::invalid_cell_reference)
      80                 :                :         {
      81                 :                :             split[1] = "";
      82                 :                :         }
      83                 :                : 
      84                 :                :         result.push_back({ split[0], split[1] });
      85                 :                :     }
      86                 :                : 
      87                 :                :     return result;
      88                 :                : }
      89                 :                : */
      90                 :                : 
      91                 :                : } // namespace
      92                 :                : 
      93                 :                : namespace xlnt {
      94                 :                : 
      95                 :UBC           0 : std::string named_range::name() const
      96                 :                : {
      97                 :              0 :     return name_;
      98                 :                : }
      99                 :                : 
     100                 :CBC           7 : const std::vector<named_range::target> &named_range::targets() const
     101                 :                : {
     102                 :              7 :     return targets_;
     103                 :                : }
     104                 :                : 
     105                 :             10 : named_range::named_range()
     106                 :                : {
     107                 :             10 : }
     108                 :                : 
     109                 :UBC           0 : named_range::named_range(const named_range &other)
     110                 :                : {
     111            [ # ]:              0 :     *this = other;
     112                 :              0 : }
     113                 :                : 
     114                 :CBC          10 : named_range::named_range(const std::string &name, const std::vector<named_range::target> &targets)
     115            [ + ]:             10 :     : name_(name), targets_(targets)
     116                 :                : {
     117                 :             10 : }
     118                 :                : 
     119                 :             10 : named_range &named_range::operator=(const named_range &other)
     120                 :                : {
     121                 :             10 :     name_ = other.name_;
     122                 :             10 :     targets_ = other.targets_;
     123                 :                : 
     124                 :             10 :     return *this;
     125                 :                : }
     126                 :                : 
     127                 :UBC           0 : bool named_range::operator==(const named_range &rhs) const
     128                 :                : {
     129                 :              0 :     return name_ == rhs.name_
     130   [ #  #  #  # ]:              0 :         && targets_ == rhs.targets_;
     131                 :                : }
     132                 :                : 
     133                 :              0 : bool named_range::operator!=(const named_range &rhs) const
     134                 :                : {
     135                 :              0 :     return !(*this == rhs);
     136                 :                : }
     137                 :                : 
     138                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta