// Copyright (c) 2014-2021 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE // // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file #pragma once #include #include #include #include #include #include #include namespace xlnt { class cell; class cell_iterator; class const_cell_iterator; class range_reference; /// /// A cell vector is a linear (1D) range of cells, either vertical or horizontal /// depending on the major order specified in the constructor. /// class XLNT_API cell_vector { public: /// /// Iterate over cells in a cell_vector with an iterator of this type. /// using iterator = cell_iterator; /// /// Iterate over const cells in a const cell_vector with an iterator of this type. /// using const_iterator = const_cell_iterator; /// /// Iterate over cells in a cell_vector in reverse oreder with an iterator /// of this type. /// using reverse_iterator = std::reverse_iterator; /// /// Iterate over const cells in a const cell_vector in reverse order with /// an iterator of this type. /// using const_reverse_iterator = std::reverse_iterator; /// /// Constructs a cell vector pointing to a given range in a given worksheet. /// order determines whether this vector is a row or a column. If skip_null is /// true, iterating over this vector will skip empty cells. /// cell_vector(worksheet ws, const cell_reference &cursor, const range_reference &ref, major_order order, bool skip_null, bool wrap); /// /// Returns true if every cell in this vector is null (i.e. the cell doesn't exist in the worksheet). /// bool empty() const; /// /// Returns the first cell in this vector. /// cell front(); /// /// Returns the first cell in this vector. /// const cell front() const; /// /// Returns the last cell in this vector. /// cell back(); /// /// Returns the last cell in this vector. /// const cell back() const; /// /// Returns the distance between the first and last cells in this vector. /// std::size_t length() const; /// /// Returns an iterator to the first cell in this vector. /// iterator begin(); /// /// Returns an iterator to a cell one-past-the-end of this vector. /// iterator end(); /// /// Returns an iterator to the first cell in this vector. /// const_iterator begin() const; /// /// Returns an iterator to the first cell in this vector. /// const_iterator cbegin() const; /// /// Returns an iterator to a cell one-past-the-end of this vector. /// const_iterator end() const; /// /// Returns an iterator to a cell one-past-the-end of this vector. /// const_iterator cend() const; /// /// Returns a reverse iterator to the first cell of this reversed vector. /// reverse_iterator rbegin(); /// /// Returns a reverse iterator to to a cell one-past-the-end of this reversed vector. /// reverse_iterator rend(); /// /// Returns a reverse iterator to the first cell of this reversed vector. /// const_reverse_iterator rbegin() const; /// /// Returns a reverse iterator to to a cell one-past-the-end of this reversed vector. /// const_reverse_iterator rend() const; /// /// Returns a reverse iterator to the first cell of this reversed vector. /// const_reverse_iterator crbegin() const; /// /// Returns a reverse iterator to to a cell one-past-the-end of this reversed vector. /// const_reverse_iterator crend() const; /// /// Returns the cell column_index distance away from the first cell in this vector. /// cell operator[](std::size_t column_index); /// /// Returns the cell column_index distance away from the first cell in this vector. /// const cell operator[](std::size_t column_index) const; private: /// /// The worksheet this vector points to cells from /// worksheet ws_; /// /// The reference of the first cell in this vector /// cell_reference cursor_; /// /// The range of cells this vector can point to /// range_reference bounds_; /// /// The direction that iteration over this vector will move. Note that /// this has the opposite meaning as in a range_iterator because after /// getting a row-major range_iterator, the row-major cell_iterator will /// iterate over a column and vice versa. /// major_order order_; /// /// If true, cells that don't exist in the worksheet will be skipped during iteration. /// bool skip_null_; /// /// If true, when on the last column, the cursor will continue to the next row /// (and vice versa when iterating in column-major order) until reaching the /// bottom right corner of the range. /// bool wrap_; }; } // namespace xlnt