mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
worksheet_iterator - rule of 5/0
For rule of 5/0, where no implementation is required, all 5 operations have been declared as defaulted. This is less likely to forget definitions for all 5 if required - removed forwarding of copy ctor to assignment (which was defaulted already) in favour of defaulted copy ctor - added defaulted move assignment/ctor and destructor Changed workbook reference to a pointer to allow tests to compile (reference isn't rebindable so defaulted assignment is equivalent to deleted)
This commit is contained in:
parent
eaf3c2a773
commit
a47985b2db
|
@ -61,12 +61,27 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Copy constructs a worksheet iterator from another iterator.
|
/// Copy constructs a worksheet iterator from another iterator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
worksheet_iterator(const worksheet_iterator &);
|
worksheet_iterator(const worksheet_iterator &) = default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Assigns the iterator so that it points to the same worksheet in the same workbook.
|
/// Assigns the iterator so that it points to the same worksheet in the same workbook.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
worksheet_iterator &operator=(const worksheet_iterator &);
|
worksheet_iterator &operator=(const worksheet_iterator &) = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copy constructs a worksheet iterator from another iterator.
|
||||||
|
/// </summary>
|
||||||
|
worksheet_iterator(worksheet_iterator &&) = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Assigns the iterator so that it points to the same worksheet in the same workbook.
|
||||||
|
/// </summary>
|
||||||
|
worksheet_iterator &operator=(worksheet_iterator &&) = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default destructor
|
||||||
|
/// </summary>
|
||||||
|
~worksheet_iterator() = default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dereferences the iterator to return the worksheet it is pointing to.
|
/// Dereferences the iterator to return the worksheet it is pointing to.
|
||||||
|
@ -101,7 +116,7 @@ private:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target workbook of this iterator.
|
/// The target workbook of this iterator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
workbook &wb_;
|
workbook *wb_;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The index of the worksheet in wb_ this iterator is currently pointing to.
|
/// The index of the worksheet in wb_ this iterator is currently pointing to.
|
||||||
|
@ -133,12 +148,27 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Copy constructs a worksheet iterator from another iterator.
|
/// Copy constructs a worksheet iterator from another iterator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const_worksheet_iterator(const const_worksheet_iterator &);
|
const_worksheet_iterator(const const_worksheet_iterator &) = default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Assigns the iterator so that it points to the same worksheet in the same workbook.
|
/// Assigns the iterator so that it points to the same worksheet in the same workbook.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const_worksheet_iterator &operator=(const const_worksheet_iterator &);
|
const_worksheet_iterator &operator=(const const_worksheet_iterator &) = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Move constructs a worksheet iterator from another iterator.
|
||||||
|
/// </summary>
|
||||||
|
const_worksheet_iterator(const_worksheet_iterator &&) = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Assigns the iterator from a temporary
|
||||||
|
/// </summary>
|
||||||
|
const_worksheet_iterator &operator=(const_worksheet_iterator &&) = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default destructor
|
||||||
|
/// </summary>
|
||||||
|
~const_worksheet_iterator() = default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dereferences the iterator to return the worksheet it is pointing to.
|
/// Dereferences the iterator to return the worksheet it is pointing to.
|
||||||
|
@ -173,7 +203,7 @@ private:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target workbook of this iterator.
|
/// The target workbook of this iterator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const workbook &wb_;
|
const workbook *wb_;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The index of the worksheet in wb_ this iterator is currently pointing to.
|
/// The index of the worksheet in wb_ this iterator is currently pointing to.
|
||||||
|
|
|
@ -28,18 +28,13 @@
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
|
||||||
worksheet_iterator::worksheet_iterator(workbook &wb, std::size_t index)
|
worksheet_iterator::worksheet_iterator(workbook &wb, std::size_t index)
|
||||||
: wb_(wb), index_(index)
|
: wb_(&wb), index_(index)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
worksheet_iterator::worksheet_iterator(const worksheet_iterator &rhs)
|
|
||||||
: wb_(rhs.wb_), index_(rhs.index_)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
worksheet worksheet_iterator::operator*()
|
worksheet worksheet_iterator::operator*()
|
||||||
{
|
{
|
||||||
return wb_[index_];
|
return (*wb_)[index_];
|
||||||
}
|
}
|
||||||
|
|
||||||
worksheet_iterator &worksheet_iterator::operator++()
|
worksheet_iterator &worksheet_iterator::operator++()
|
||||||
|
@ -50,7 +45,7 @@ worksheet_iterator &worksheet_iterator::operator++()
|
||||||
|
|
||||||
worksheet_iterator worksheet_iterator::operator++(int)
|
worksheet_iterator worksheet_iterator::operator++(int)
|
||||||
{
|
{
|
||||||
worksheet_iterator old(wb_, index_);
|
worksheet_iterator old(*wb_, index_);
|
||||||
++*this;
|
++*this;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
@ -65,25 +60,14 @@ bool worksheet_iterator::operator!=(const worksheet_iterator &comparand) const
|
||||||
return !(*this == comparand);
|
return !(*this == comparand);
|
||||||
}
|
}
|
||||||
|
|
||||||
worksheet_iterator &worksheet_iterator::operator=(const worksheet_iterator &other)
|
|
||||||
{
|
|
||||||
index_ = other.index_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const_worksheet_iterator::const_worksheet_iterator(const workbook &wb, std::size_t index)
|
const_worksheet_iterator::const_worksheet_iterator(const workbook &wb, std::size_t index)
|
||||||
: wb_(wb), index_(index)
|
: wb_(&wb), index_(index)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const_worksheet_iterator::const_worksheet_iterator(const const_worksheet_iterator &rhs)
|
|
||||||
: wb_(rhs.wb_), index_(rhs.index_)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const worksheet const_worksheet_iterator::operator*()
|
const worksheet const_worksheet_iterator::operator*()
|
||||||
{
|
{
|
||||||
return wb_.sheet_by_index(index_);
|
return wb_->sheet_by_index(index_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_worksheet_iterator &const_worksheet_iterator::operator++()
|
const_worksheet_iterator &const_worksheet_iterator::operator++()
|
||||||
|
@ -94,7 +78,7 @@ const_worksheet_iterator &const_worksheet_iterator::operator++()
|
||||||
|
|
||||||
const_worksheet_iterator const_worksheet_iterator::operator++(int)
|
const_worksheet_iterator const_worksheet_iterator::operator++(int)
|
||||||
{
|
{
|
||||||
const_worksheet_iterator old(wb_, index_);
|
const_worksheet_iterator old(*wb_, index_);
|
||||||
++*this;
|
++*this;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user