xlnt
cell_vector.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2024 xlnt-community
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE
21 //
22 // @license: http://www.opensource.org/licenses/mit-license.php
23 // @author: see AUTHORS file
24 
25 #pragma once
26 
27 #include <iterator>
28 
29 #include <xlnt/xlnt_config.hpp>
30 #include <xlnt/cell/cell_reference.hpp>
31 #include <xlnt/worksheet/cell_iterator.hpp>
32 #include <xlnt/worksheet/major_order.hpp>
33 #include <xlnt/worksheet/range_reference.hpp>
34 #include <xlnt/worksheet/worksheet.hpp>
35 
36 namespace xlnt {
37 
38 class cell;
39 class cell_iterator;
40 class const_cell_iterator;
41 class range_reference;
42 
47 class XLNT_API cell_vector
48 {
49 public:
54 
59 
64  using reverse_iterator = std::reverse_iterator<iterator>;
65 
70  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
71 
77  cell_vector(worksheet ws, const cell_reference &cursor,
78  const range_reference &ref, major_order order, bool skip_null, bool wrap);
79 
83  bool empty() const;
84 
88  cell front();
89 
93  const cell front() const;
94 
98  cell back();
99 
103  const cell back() const;
104 
108  std::size_t length() const;
109 
113  iterator begin();
114 
118  iterator end();
119 
123  const_iterator begin() const;
124 
128  const_iterator cbegin() const;
129 
133  const_iterator end() const;
134 
138  const_iterator cend() const;
139 
143  reverse_iterator rbegin();
144 
148  reverse_iterator rend();
149 
153  const_reverse_iterator rbegin() const;
154 
158  const_reverse_iterator rend() const;
159 
163  const_reverse_iterator crbegin() const;
164 
168  const_reverse_iterator crend() const;
169 
173  cell operator[](std::size_t column_index);
174 
178  const cell operator[](std::size_t column_index) const;
179 
180 private:
184  worksheet ws_;
185 
189  cell_reference cursor_;
190 
194  range_reference bounds_;
195 
202  major_order order_;
203 
207  bool skip_null_;
208 
214  bool wrap_;
215 };
216 
217 } // namespace xlnt
A cell iterator iterates over a 1D range by row or by column.
Definition: cell_iterator.hpp:187
std::reverse_iterator< iterator > reverse_iterator
Iterate over cells in a cell_vector in reverse oreder with an iterator of this type.
Definition: cell_vector.hpp:64
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
A worksheet is a 2D array of cells starting with cell A1 in the top-left corner and extending indefin...
Definition: worksheet.hpp:77
major_order
Defines whether iterating a range returns columns or rows sequentially.
Definition: major_order.hpp:34
An object used to refer to a cell. References have two parts, the column and the row. In Excel, the reference string A1 refers to the top-left-most cell. A cell_reference can be initialized from a string of this form or a 1-indexed ordered pair of the form column, row.
Definition: cell_reference.hpp:60
Describes a unit of data in a worksheet at a specific coordinate and its associated properties...
Definition: cell.hpp:84
A cell iterator iterates over a 1D range by row or by column.
Definition: cell_iterator.hpp:48
A cell vector is a linear (1D) range of cells, either vertical or horizontal depending on the major o...
Definition: cell_vector.hpp:47
A range_reference describes a rectangular area of a worksheet with positive width and height defined ...
Definition: range_reference.hpp:36
std::reverse_iterator< const_iterator > const_reverse_iterator
Iterate over const cells in a const cell_vector in reverse order with an iterator of this type...
Definition: cell_vector.hpp:70