differential code coverage report with master
Current view: top level - source/detail/implementations - format_impl.hpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 100.0 % 39 39 39
Current Date: 2025-12-07 02:01:22 Functions: 100.0 % 20 20 20
Baseline: coverage_master.info Branches: 67.6 % 37 25 24 50
Baseline Date: 2025-12-07 02:01:21

             Branch data    TLA  Line data    Source code
       1                 :                : #pragma once
       2                 :                : 
       3                 :                : #include <cstddef>
       4                 :                : #include <memory>
       5                 :                : 
       6                 :                : #include <detail/xlnt_config_impl.hpp>
       7                 :                : 
       8                 :                : #include <xlnt/internal/format_impl_ptr.hpp>
       9                 :                : #include <xlnt/styles/alignment.hpp>
      10                 :                : #include <xlnt/styles/border.hpp>
      11                 :                : #include <xlnt/styles/fill.hpp>
      12                 :                : #include <xlnt/styles/font.hpp>
      13                 :                : #include <xlnt/styles/number_format.hpp>
      14                 :                : #include <xlnt/styles/protection.hpp>
      15                 :                : #include <xlnt/utils/optional.hpp>
      16                 :                : 
      17                 :                : namespace xlnt {
      18                 :                : 
      19                 :                : class alignment;
      20                 :                : class border;
      21                 :                : class fill;
      22                 :                : class font;
      23                 :                : class number_format;
      24                 :                : class protection;
      25                 :                : 
      26                 :                : namespace detail {
      27                 :                : 
      28                 :                : struct stylesheet;
      29                 :                : 
      30                 :                : class references
      31                 :                : {
      32                 :                : public:
      33                 :CBC        2041 :     references() = default;
      34                 :           1119 :     references(const references& /*reference*/) {}
      35                 :              1 :     references(references&& /*reference*/) {}
      36                 :                :     ~references() = default;
      37                 :                : 
      38                 :           5400 :     operator std::size_t() const {return count;}
      39                 :                : 
      40                 :           3405 :     references& operator++ () {++count; return *this;}
      41                 :           3403 :     references& operator-- () {--count; return *this;}
      42                 :                : 
      43                 :           1095 :     references& operator = (const references& /*reference*/) {return *this;}
      44                 :              1 :     references& operator = (references&& /*reference*/) {return *this;}
      45                 :                : 
      46                 :                : private:
      47                 :                :     std::size_t count = 0;
      48                 :                : };
      49                 :                : 
      50                 :                : struct format_impl
      51                 :                : {
      52                 :                :         stylesheet *parent = nullptr;
      53                 :                : 
      54                 :                :         std::size_t id = 0;
      55                 :                : 
      56                 :                :         optional<std::size_t> alignment_id;
      57                 :                :         optional<std::size_t> border_id;
      58                 :                :     optional<std::size_t> fill_id;
      59                 :                :     optional<std::size_t> font_id;
      60                 :                :     optional<std::size_t> number_format_id;
      61                 :                :     optional<std::size_t> protection_id;
      62                 :                : 
      63                 :                :     optional<bool> alignment_applied;
      64                 :                :     optional<bool> border_applied;
      65                 :                :     optional<bool> fill_applied;
      66                 :                :     optional<bool> font_applied;
      67                 :                :     optional<bool> number_format_applied;
      68                 :                :     optional<bool> protection_applied;
      69                 :                : 
      70                 :                :     bool pivot_button_ = false;
      71                 :                :     bool quote_prefix_ = false;
      72                 :                : 
      73                 :                :         optional<std::string> style;
      74                 :                : 
      75                 :           1236 :     friend bool operator==(const format_impl &left, const format_impl &right)
      76                 :                :     {
      77                 :                :         // not comparing parent
      78                 :           1236 :         return left.alignment_id == right.alignment_id
      79         [ +  - ]:           1235 :             && left.alignment_applied == right.alignment_applied
      80         [ +  + ]:           1235 :             && left.border_id == right.border_id
      81         [ +  - ]:           1172 :             && left.border_applied == right.border_applied
      82         [ +  + ]:           1172 :             && left.fill_id == right.fill_id
      83         [ +  - ]:           1164 :             && left.fill_applied == right.fill_applied
      84         [ +  + ]:           1164 :             && left.font_id == right.font_id
      85         [ +  - ]:           1148 :             && left.font_applied == right.font_applied
      86         [ +  + ]:           1148 :             && left.number_format_id == right.number_format_id
      87         [ +  - ]:           1120 :             && left.number_format_applied == right.number_format_applied
      88         [ +  - ]:           1120 :             && left.protection_id == right.protection_id
      89         [ +  - ]:           1120 :             && left.protection_applied == right.protection_applied
      90         [ +  - ]:           1120 :             && left.pivot_button_ == right.pivot_button_
      91         [ +  - ]:           1120 :             && left.quote_prefix_ == right.quote_prefix_
      92   [ +  +  +  + ]:           2471 :             && left.style == right.style;
      93                 :                :     }
      94                 :                : 
      95                 :            871 :     bool is_used () const {return references > 0;}
      96                 :           1111 :     bool is_shared () const {return references > 1;}
      97                 :                : 
      98                 :                : private:
      99                 :                :     class references references;
     100                 :                :     friend class format_impl_ptr;
     101                 :                : };
     102                 :                : 
     103                 :                : class format_impl_list_item
     104                 :                : {
     105                 :                : public:
     106                 :            751 :     format_impl_list_item() : format_(new format_impl()) {}
     107      [ +  -  - ]:              7 :     format_impl_list_item(const format_impl& R) : format_(new format_impl(R)) {}
     108                 :                :     format_impl_list_item(const format_impl_list_item& R) : format_impl_list_item(*R.format_) {}
     109                 :                :     format_impl_list_item(format_impl_list_item&& R) = default;
     110                 :            758 :     ~format_impl_list_item() = default;
     111                 :                : 
     112                 :                :     format_impl_list_item& operator=(const format_impl& R) {format_.reset(new format_impl(R)); return *this;}
     113                 :                :     format_impl_list_item& operator=(const format_impl_list_item& R) {return operator =(*R.format_);}
     114                 :                :     format_impl_list_item& operator=(format_impl_list_item&& R) = default;
     115                 :                : 
     116                 :           2846 :     format_impl* operator->() {return format_.get();}
     117                 :           1926 :     format_impl& operator* () {return *format_;}
     118                 :            183 :     const format_impl& operator* () const {return *format_;}
     119                 :           2307 :     operator format_impl_ptr() {return format_.get();}
     120                 :                : 
     121                 :              8 :     bool operator==(const format_impl_list_item& R) const {return *format_ == *R.format_;}
     122                 :                : 
     123                 :                : protected:
     124                 :                :     struct D
     125                 :                :     {
     126                 :            758 :         void operator()(format_impl* impl) const
     127                 :                :         {
     128         [ +  + ]:            758 :             if (impl->is_used())
     129                 :            330 :                 impl->parent = nullptr; // will be destructed by format_impl_ptr::decrement
     130                 :                :             else
     131         [ +  - ]:            428 :                 delete impl;
     132                 :            758 :         }
     133                 :                :     };
     134                 :                : 
     135                 :                :     std::unique_ptr<format_impl, D> format_;
     136                 :                : };
     137                 :                : 
     138                 :                : } // namespace detail
     139                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta