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/workbook/workbook.hpp>
26 : : #include <xlnt/workbook/worksheet_iterator.hpp>
27 : : #include <xlnt/worksheet/worksheet.hpp>
28 : :
29 : : namespace xlnt {
30 : :
31 :CBC 676 : worksheet_iterator::worksheet_iterator(workbook &wb, std::size_t index)
32 : 676 : : wb_(&wb), index_(index)
33 : : {
34 : 676 : }
35 : :
36 : 114 : worksheet_iterator::reference worksheet_iterator::operator*()
37 : : {
38 : 114 : return (*wb_)[index_];
39 : : }
40 : :
41 :UBC 0 : const worksheet_iterator::reference worksheet_iterator::operator*() const
42 : : {
43 : 0 : return (*wb_)[index_];
44 : : }
45 : :
46 :CBC 107 : worksheet_iterator &worksheet_iterator::operator++()
47 : : {
48 : 107 : index_++;
49 : 107 : return *this;
50 : : }
51 : :
52 : 8 : worksheet_iterator worksheet_iterator::operator++(int)
53 : : {
54 : 8 : worksheet_iterator old(*wb_, index_);
55 : 8 : ++*this;
56 : 8 : return old;
57 : : }
58 : :
59 : 2 : worksheet_iterator &worksheet_iterator::operator--()
60 : : {
61 : 2 : --index_;
62 : 2 : return *this;
63 : : }
64 : :
65 : 1 : worksheet_iterator worksheet_iterator::operator--(int)
66 : : {
67 : 1 : worksheet_iterator old(*wb_, index_);
68 : 1 : --(*this);
69 : 1 : return old;
70 : : }
71 : :
72 : 437 : bool worksheet_iterator::operator==(const worksheet_iterator &comparand) const
73 : : {
74 [ + + + + ]: 437 : return index_ == comparand.index_ && wb_ == comparand.wb_;
75 : : }
76 : :
77 : 429 : bool worksheet_iterator::operator!=(const worksheet_iterator &comparand) const
78 : : {
79 : 429 : return !(*this == comparand);
80 : : }
81 : :
82 : 2400 : const_worksheet_iterator::const_worksheet_iterator(const workbook &wb, std::size_t index)
83 : 2400 : : wb_(&wb), index_(index)
84 : : {
85 : 2400 : }
86 : :
87 : 1211 : const const_worksheet_iterator::reference const_worksheet_iterator::operator*() const
88 : : {
89 : 1211 : return wb_->sheet_by_index(index_);
90 : : }
91 : :
92 : 1138 : const_worksheet_iterator &const_worksheet_iterator::operator++()
93 : : {
94 : 1138 : index_++;
95 : 1138 : return *this;
96 : : }
97 : :
98 : 5 : const_worksheet_iterator const_worksheet_iterator::operator++(int)
99 : : {
100 : 5 : const_worksheet_iterator old(*wb_, index_);
101 : 5 : ++*this;
102 : 5 : return old;
103 : : }
104 : :
105 : 2 : const_worksheet_iterator &const_worksheet_iterator::operator--()
106 : : {
107 : 2 : --index_;
108 : 2 : return *this;
109 : : }
110 : :
111 : 1 : const_worksheet_iterator const_worksheet_iterator::operator--(int)
112 : : {
113 : 1 : const_worksheet_iterator old(*wb_, index_);
114 : 1 : --(*this);
115 : 1 : return old;
116 : : }
117 : :
118 : 2340 : bool const_worksheet_iterator::operator==(const const_worksheet_iterator &comparand) const
119 : : {
120 [ + + + + ]: 2340 : return index_ == comparand.index_ && wb_ == comparand.wb_;
121 : : }
122 : :
123 : 2325 : bool const_worksheet_iterator::operator!=(const const_worksheet_iterator &comparand) const
124 : : {
125 : 2325 : return !(*this == comparand);
126 : : }
127 : :
128 : : } // namespace xlnt
|