xlnt/include/xlnt/worksheet/range.hpp

222 lines
4.8 KiB
C++
Raw Normal View History

2015-12-25 06:10:02 +08:00
// Copyright (c) 2014-2016 Thomas Fussell
2014-06-06 04:19:31 +08:00
//
// 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, WRISING 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
2014-05-22 05:48:51 +08:00
#pragma once
#include <iterator>
2014-05-22 05:48:51 +08:00
#include <memory>
#include <string>
#include <vector>
#include <xlnt/xlnt_config.hpp>
2015-11-02 14:07:43 +08:00
#include <xlnt/worksheet/cell_vector.hpp>
#include <xlnt/worksheet/major_order.hpp>
2016-01-25 00:15:49 +08:00
#include <xlnt/worksheet/const_range_iterator.hpp>
#include <xlnt/worksheet/range_iterator.hpp>
2015-11-02 14:07:43 +08:00
#include <xlnt/worksheet/range_reference.hpp>
#include <xlnt/worksheet/worksheet.hpp>
2014-05-22 05:48:51 +08:00
namespace xlnt {
2016-01-25 00:15:49 +08:00
class const_range_iterator;
class range_iterator;
/// <summary>
/// A range is a 2D collection of cells with defined extens that can be iterated upon.
/// </summary>
class XLNT_API range
2014-05-22 05:48:51 +08:00
{
2016-01-18 14:23:31 +08:00
public:
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2016-01-25 00:15:49 +08:00
using iterator = range_iterator;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2016-01-25 00:15:49 +08:00
using const_iterator = const_range_iterator;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
using reverse_iterator = std::reverse_iterator<iterator>;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
2016-01-18 14:23:31 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
range(worksheet ws, const range_reference &reference, major_order order = major_order::row, bool skip_null = false);
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
~range();
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
range(const range &) = default;
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-07-20 04:59:05 +08:00
cell_vector operator[](std::size_t vector_index);
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-07-20 04:59:05 +08:00
const cell_vector operator[](std::size_t vector_index) const;
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
bool operator==(const range &comparand) const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool operator!=(const range &comparand) const;
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-07-20 04:59:05 +08:00
cell_vector get_vector(std::size_t vector_index);
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-07-20 04:59:05 +08:00
const cell_vector get_vector(std::size_t vector_index) const;
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
cell get_cell(const cell_reference &ref);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
const cell get_cell(const cell_reference &ref) const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
range_reference get_reference() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-07-20 04:59:05 +08:00
std::size_t length() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool contains(const cell_reference &ref);
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
iterator begin();
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
iterator end();
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
const_iterator begin() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
const_iterator end() const;
2014-05-22 05:48:51 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
const_iterator cbegin() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
const_iterator cend() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
reverse_iterator rbegin();
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
reverse_iterator rend();
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
const_reverse_iterator rbegin() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
const_reverse_iterator rend() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
const_reverse_iterator crbegin() const;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
const_reverse_iterator crend() const;
2014-05-22 05:48:51 +08:00
2016-01-18 14:23:31 +08:00
private:
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
worksheet ws_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
2014-05-22 05:48:51 +08:00
range_reference ref_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
major_order order_;
2016-11-20 14:01:32 +08:00
/// <summary>
///
/// </summary>
bool skip_null_;
2014-05-22 05:48:51 +08:00
};
} // namespace xlnt